I was wondering, how exactly do you go to a certain character number in a file? so suppose I was to open a file, and then wanted to obtain character number 26 from that file, how would I do it?
I was wondering, how exactly do you go to a certain character number in a file? so suppose I was to open a file, and then wanted to obtain character number 26 from that file, how would I do it?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Well ... to be fully cross-platform compatible, you would call get() 26 times. The seekg() effects are undefined for text mode streams.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
How would one go about using the get function to do it? I assume that it needs to be called 26 times because there are 26 letters in the alphabet (english one anyway), so presumably, the function works by scanning the file for the letter 'a' and then scans again for 'b' etc, and prints all the a's and then all the b's, and so on.
hmm... actually, in that case you may be able to use ignore(25) followed by a single get().
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
how would you go about doing this in C rather than using C++?
With fgetc().
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law