Hi guys,
So I have this text file that I am trying to read from and store the values of each line in multiple variables.
Let's say my text file contains
and my code below here works fine when the lines in the text file is separated by spaces.
while (fscanf(fp, "%s %s %d %d\n", userID, name, &startLoc, &endLoc) != EOF) {
printf("%s %s %d %d\n", userID, name, startLoc, endLoc);
}
|
But let's say my file was to look like this instead.
But if i try this below...
while (fscanf(fp, "%s:%s:%d:%d\n", userID, name, &startLoc, &endLoc) != EOF) {
printf("%s %s %d %d\n", userID, name, startLoc, endLoc);
}
|
It seem to store the entire line in userID including the ":". I want to ignore the ":"'s and store everything in between in respective varibles in the order specified above.
So first string in userID, then ignore the :, then second string in name, and ignore the next :, and so forth.
Any idea how I can accomplish this? Any help would be greatly appreciated.
Thanks in advance. :)
Cheers