while arrays problem

so i want a program that reads from a file with the format: name, gender.
but the name can either be 1,2 or 3 words.

so i was thinking to calculate the number of words and then assign to arrays
am i on the right track?

thanks for your help in advance
Last edited on
If the format actually is "name, gender" and not "name gender", then you can just use getline(blah, blah, ',');
huh... i wish I had known that before...

so it will either get a line, or 'get' until the 3rd char arg is reached?

that is awsome and I'm trying that out right now, lol

Also, another thing:

couldn't you just out it with a space in between, and then getline(in, line, ' ');?
Last edited on
Well if the name has spaces in it that won't work, and in any case it has the same behavior as the >> operator, which is that it reads until it gets a space.
Heyy no it doesnt have commas seperating it ... just space...
e.g. Joe John M
Eliza Beth Lo F
Last edited on
Well, you can check how many words there are and you know that the last one is the gender. I think this is what you wanted to do but it certainly isn't what you programmed.
Last edited on
Topic archived. No new replies allowed.