I made a basic C++ program to read a one line text file that does not include any newline character which looks like this:
ifstream ifs;
ifs.open(filename);
char c;
int cint;
while (ifs >> noskipws >> c) {
cint = c;
cout << "'" << c << "' = " << cint << endl;
}
The thing is; while it reads everything that I wanted it also reads a non-existing newline character at the end which prints 10 for its ASCII number. I am using g++ and I deleted the file and rewrote basic test cases but it always gets a newline character at the end. What may be the reason for it?
Aucun commentaire:
Enregistrer un commentaire