my general question is why can't i set value 0 to the seekg function?
I know it works with object.open("file", ios::ate); but that's not a qustion now, plese help.
tnx for your reply, object.seekg (-1, ios::end); works fine, but would like to understand what does exactly mean when we pass 0: object.seekg (0, ios::end);
sorry if I'm being boring but if it returns end of line which is '\n' then why can't we copy it?
'\n' character is just like any other so it's not an error :|?
one thing i dont understand that why are positioned the object.seekg (0, ios::end); //ERROR
to the begining imedialty after when you check for the file open .. when the file is open it is suppose to be at the begning of the file .
Correct me if i am wrong .
@bluecoder
hi, I'm not shore if I understand what are you saying but:
1 2
object.seekg (0, ios::beg); //this works, put the "file pointer" to the begining
object.seekg (0, ios::end); //this is same as above but "file pointer should point to the end
first line works just fine and is supposted to move "file pointer" to the beginging when your file pointer is somewere else in the file.
second line is eqivalent to the first but it's not working in same way as first line does and I don't know why?
second line moves file pointer to the end.
thanks.
@Rishi Rai
'\n' is interpreted as new line not end of line.
woot?
I didn't know that lol
--------
is there some good refecernce to learn about files and symbols like EOF EOL and similar?
thanks.
so at the end of file last line in the file at the end is EOL and EOF in same time while all other lines ends are EOL only.
that means there is no char at EOL or EOF and that the reason why object.seekg (0, ios::end); does not work(but works for taking length of the file in bytes)
thanks for explanation.