Having trouble accessing strings within an Array:/ Please help.
I am working on a program that has an input file like this:
3
Adam Bob John
Kathy Jennifer Whitney
3 is the number of each gender.
All the men names are separated by a space. All the women names are also separated by a space.
How do I read in all the names into an array and then access ONE name from each line?
I tried something like:
Code:
for (i=0; i < numPairs; i++){
fscanf(ifp, "%s", &nameOfPerson)
}
Where nameOfPerson is declared as an char array of size 20 (since each name is 20 characters in length max).
So how would I access the name bob skipping the rest of the names? or how would I access the name whitney skipping the rest of the names?
Thanks in advnace!
(Please give me a helpful answer b/c I am working a big comparison project in Computer science where I need to use recursion and I do not want to spend too much time on figuring out generalized hints)