Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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++;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote