Don\'t need finished code of it done, just need an explination of how to do it.
ID: 3542322 • Letter: D
Question
Don't need finished code of it done, just need an explination of how to do it. I need to write a program that takes data from a input line and puts different peices of the line into different variables. Basically like a grading program where if someone input the line "Mark 89 85" it would store mark under the name variable, 89 under the test 1 variable, and 85 under the test 2 variable. I know how to do this if I had to input each thing in 3 different times in 3 different input cases, but not how to seperate all 3 from the same line. Can somone please explain?
Explanation / Answer
in C++,
ifstream infile("file_to_read");
string name[3];
int test1[3];
int test2[3];
int index =0;
while(!infile.eof())
{
// file stream operator has faclitiy to read single line to multiple variable as follows.
infile >> name[index] >> test1[index] >> test2[index];
index++;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.