Hi, I was trying to create class through which I could read specific characters in a file using operator[] and it kind of worked.
It was working if there was only a single long line but if there were multiple lines in my file I got an extra new line for every new line, for example :
File:
For streams opened in text mode, seeks to arbitrary positions are not supported (both C and C++).
a. Open the file in binary mode (read byte by byte, without escape sequence translations).
b. Streams opened in binary mode are not required to support seek to the end; so check for seek failure.
c. EDIT: Use std::streamsizestd::streamoff instead of std::size_t
Thank you guys, much appreciated :) This opening in binary mode really fixed this. Link was cool as well!
PS. Does "Standard C++ IOStreams and Locales: Advanced Programmer's Guide and Reference" talks about "problems" such as this? I'm considering buying it and just wanted to know how detailed it is. Not that there are any better book about the topic anyway so this questions is probably pointless :D Just curiosity!
std::fseek
If the stream is open in text mode, the only supported values for offset are zero (which works with any origin) and a value returned by an earlier call to std::ftell on a stream associated with the same file (which only works with origin of SEEK_SET. http://en.cppreference.com/w/cpp/io/c/fseek
> Does "Standard C++ IOStreams and Locales: Advanced Programmer's Guide and Reference" talks about "problems" such as this?
> I'm considering buying it and just wanted to know how detailed it is.