I need my program to read a line of a file, and then parse the line and insert any words into an index of each array. The only problem is that I don't know how many words there are per line, it can be 1-6 words per line.
So this is what a simple file can look like:
apple oranges
computer terminal keyboard mouse
I would need a char array to hold the words apple and oranges if I am scanning line 1. Example:
words[0][0] = "apple";
words[1][0] = "oranges";
So far, I have something like this, but how can I make it so it works with fewer than 6 words per line?
fscanf(file, "%19[^ ] %19[^ ] %19[^ ] %19[^ ] %19[^ ] %19[^ ]", string1, string2, string3, string4, string5, string6);