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?
Well ... to be fully cross-platform compatible, you would call get() 26 times. The seekg() effects are undefined for text mode streams.
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().
how would you go about doing this in C rather than using C++?
With fgetc().