/* * There seems to be a problem with C++ instream.get(char) * This program tests it and tests the C alternative */ #include #include int main (int argc, char **argv) { ifstream stream; FILE *file; unsigned char ch; unsigned long long int n=0; stream.open ("test.txt"); if( stream.rdstate() != 0 ) { cerr << "Couldn't open input file" << endl; exit (1); } while (!stream.eof()) { stream.get (ch); n++; } stream.close (); cout << "file ended after " << n << " bytes" << endl; n=0; file = fopen ("test.txt","r"); while (!feof(file)) { ch = fgetc (file); n++; } fclose (file); cout << "file ended after " << n << " bytes" << endl; return 0; }