I am trying to read in names and telephone numbers from a text file using fscanf.
The format of the data is:
9073234 Colwer, Mrs J.
3823823 Le Boeuf, Mr S.
To do this I am using the following line:
fscanf(fpp,"%d %s %[^\n]s",&a,surnames,firstnames);
This works except for "Le Boeuf" where it stores "Le" as the surname and "Boeuf, Mr S" in the first name (it should have "Le Boeuf" as the surname and "Mr S" as the firstname). Someone helped me with the above line, and so I don't really understand what the [^\n] does. The point is that %[^\n]s seems to allows spaces but %s doesn't. What I need is for anything before the comma to be included in the surname, even if there is a space in the surname. Can anyone help me with amending the line? I want to keep using fscanf if possible.
Many thanks