fstream operator>>(unsigned long)
Posted on 2004-10-08
I am trying to read some data from a file into unsigned long variables and it does not work. Can anyone help?
using namespace std;
unsigned long aLong = 0;
char aChar = 0;
cout << "is_open=" << in.is_open() << endl;
//in >> aLong;
in >> aChar;
//cout << "aLong='" << aLong << "'" << endl;
cout << "aChar='" << aChar << "' (" << (int)aChar << ")" << endl;
test.txt contains the following string:
my output with the two lines commented out is as follows:
my output with the two lines uncommented is as follows:
Why can I not read into an unsigned long with a function that implies that it should do this?