This is the line i’m trying to split, from the start until the :, eat any whitespace and from there onwards:
file1: file2,file3,file4
And my code is:
while(fscanf(fp,"%s: %s",map[i].name, map[i].filesNeeded) == 1)
{
printf("%s %s\n",map[i].name, map[i].filesNeeded);
i++;
}
The second parameter is never saved. the result is:
file1:
file2,file3,file4
instead of:
file1 file2,file3,file4
Firstly, fscanf will increment the return for each item matched, so it should be == 2.
Also, you will want to use %[^:] instead of %s as the %s won’t know when to stop.
Output: