everything works when I try to read from the file when I remove the Jr. from the name . How can I read the last name as Smith Jr. using this input file? I can't use get line because that reads the whole line as the full name but how can I read the name and last name separate with last name being Smith Jr. instead of causing errors?
1 2 3 4 5 6 7 8 9
Intro To Computer Science c++
SAL 343
JHG 344
John Adams
111223333 100 87 93 90 90 89 91
Willy Smith
222114444 90 73 67 -77 70 80 90
Phil Jordan
777886666 100 80 70 -50 60 90 100
When I remove Jr. from the input file it reads the last name Smith but when I place it as Smith Jr. it doesn't read it as last name and causes huge printing errors. How can I read the last name as Smith Jr. instead of removing it? thank you here's my reading function
For the name, you could use the input the way you already have, but instead read in the last name with a getline, using a . as the third parameter, which tells the getline to stop reading input when a . is encountered.
1 2
fin >> Temp.FirstName;
getline(fin, Temp.LastName, '.');
It works only for the names that have for ex. Jr. what if a name just had first and last without for ex Jr. but other than that it doesn't.. any advice i've been trying forever