Hello, Can someone please tell me how to store a first and last namebeing read f
ID: 3617060 • Letter: H
Question
Hello,Can someone please tell me how to store a first and last namebeing read from a file into a variable?
the data file contains "txt.dat" (firstname, lastname, score1,score2, score3, score4, score5)
John Doe 3 4 5 2 1
ifstream myFile; myFile.open("txt.dat");
myFile >> firstname >> lastname >> score1>> score2 >> score3 >> score4 >>score5;
so how do I store the firstname and lastname in a variable soI can recall it later?
Thanks -Mark
On a side note: Is it possible to just recall the first andlast name with one variable? instead of using two.
Can someone please tell me how to store a first and last namebeing read from a file into a variable?
the data file contains "txt.dat" (firstname, lastname, score1,score2, score3, score4, score5)
John Doe 3 4 5 2 1
ifstream myFile; myFile.open("txt.dat");
myFile >> firstname >> lastname >> score1>> score2 >> score3 >> score4 >>score5;
so how do I store the firstname and lastname in a variable soI can recall it later?
Thanks -Mark
On a side note: Is it possible to just recall the first andlast name with one variable? instead of using two.
Explanation / Answer
ifstream myFile; myFile.open("txt.dat");myFile >> firstname >> lastname >> score1>> score2 >> score3 >> score4 >>score5;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.