I am using getline
to fetch characters in buffers from an input file. After reading a line, I loop through all the characters and do a lookup on a map (for some further operations).
The problem is that once valid characters are over, my program fetches the eof from the input stream and tries to look for it in the map.
I tried checking inputStream.eof()
or eofbit
, to see when I reached the end of the stream,but the problem is that both of these get set as soon as I make the final getline()
, so I can't use it to determine where the EOF character is located in the input buffer.
How do I identify the EOF character in my input buffer and avoid looking it up in the map?
while(fileInput) {
fileInput.getline(charBuf,charBufSize);
for(int i=0; i<=charBufSize ;i++) {
char* currentChar = &(charBuf[i]);
// do something with currentChar,
// which I proceed to do by dereferencing currentChar when I need to access
// the actual character.
}
}