-
I/O help
its initialised
Code:
char num_students[MAXCHARS];
Code:
inFile.getline(num_students,MAXCHARS, ' ');
inFile>>num_students;
cout << "Number of Students" << num_students <<endl;
i get the right number .. but.. i then need to use num_students. in a for loop.. but wont let me.. cause its a char..
i change it to int.. but it doesnt work..
how to i just pull one integer from a file..
thanx
-
This will read the first integer from the file data.txt.
Code:
ifstream inFile("data.txt");
int num_students;
inFile >> num_students;
-
or you could use a get function
-
Code:
int num_students;
fin >> num_students;
~Inquirer
[EDIT]
Beaten again...
[/EDIT]
-
oh, you just found out huh? :)
-
shhhhhhhhhhhh.............
;)
~Inquirer