how to read from text file
Hey guys,
I'm having trouble reading an integer from a text file.
for example I have the following stored in a text file
------------ beginning of file------------excluding this line
H
88
------------ end of file------------excluding this line
and there are no spaces after any of the above words, each word is stored in one line.
I have an ifstream object that reads
char charVar;
int intVar;
inFile.read(reinterpret_cast(&charVar),sizeof(char));
cout <<"char value is : "<<charVar ;
inFile.read(reinterpret_cast(intVar),sizeof(int));
cout <<"int Var is : "<<intVar;
the first one works fine, ..but I cant seem to read the integer I m getting some negative numberss
and I have to use the ios::binay method to open the file,