Hi all,
I hope I'm posting in the right NG...
I have a data text file I want to read from a c++ program.
the data file goes like this:
90 # number of balls
33
42
13
45
23
...
...
I want to store the number in the first line in a variable ommitting
the following comment, then scan the rest and store it in an array.
The array I could get it done with no problem. The first line is a
problem. When I delete the "# number of balls" comment, the following
code works fine, but I need to have the comment after the number.
here's my code so far:
while (!valid) {
cout << "Name of test file: ";
cin >> filename;
#define TESTER_FILE filename
if ((tester = fopen(TESTER_FILE, "r")) == NULL)
cout << "Please enter a valid file." << endl;
else
valid = 1;
}
valid = 0;
fclose(tester);
cout << endl;
int try_with_same_data = 1;
while (try_with_same_data) {
ifstream Test_file (TESTER_FILE, ios::in);
Test_file >> BinSize;
...
...
}
How can I scan the first line, get the number and then go to next
line?
thanks for any help.
--
jvax