Multiple words from file into one string - structures

So i have a file that reads: Name, Mobile number, Gender, age

e.g. Sarah Megan 12345678 F 19
John F Dan 12345678 M 23
Paul 12345678 M 34

by using structures if the name was only one word i guess i can use
string name;
int mobile;
char gender;
int age;

cin >> name >> mobile >> gender >> age

but how would you put two or three worded names into a string?

Thank you in advance.
Last edited on
You would have to find a different way to tell apart different information in the file. Either the name has to come last so that you know the rest of the line is the name, or you need to separate things with commas so the name is the only thing with spaces.

As a last resort, you could find out how many space separated words there are and you know that the last 3 are not the name.
Last edited on
Topic archived. No new replies allowed.