I am trying to use fscanf() to read names from a text file in c. However, the names in this file are not separated by white-spaces. Can I still separate out each name using this function?
At the moment, the file contains this text :
"MARY","PATRICIA"
And when I run the following code :
FILE *nameFile;
char name1[100];
char name2[100];
nameFile = fopen("names.txt","r");
fscanf(nameFile, "%s,%s", name1, name2);
printf("name 1 : %s\n name 2 :%s\n", name1, name2);
fclose(nameFile);
I get the following output :
name1: "MARY","PATRICIA"
name2:
Is there any way of separating the names out without having spaces in the file?