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;