I have a line in a file like this: "33 sun 15:00 FCM - SIF 3 - 0".
I need to extract all of the data. I have this code so far, which makes a little error when extracting the strings "sun", "FCM" and "SIF". It makes "sun" into "sunFCMSIM", "FCM" into "FCMSIF" while "SIF" is correct.

You can just make the input file from multiple lines like the one above.
So how do I make sure that this information is extracted correct?

1 Answer
1

According to the documentation for fscanf, the s conversion specifier:

Matches a sequence of non-white-space characters; the next pointer must be a pointer to character array that is long enough to hold the input sequence and the terminating null character ('\0'), which is added automatically.

Your buffers are not large enough to accommodate the NULL terminator. If you fix that, for example by declaring outTeam, homeTeam and weekday as follows: