I am trying to figure out how to read formatted input from a file. If this were C++, I would use getline to read a line of the file and then pass that line to a stringstream. But this is the first time I am doing file I/O in C and I am stuck.

For example, the file would be in the form of:

Some Picture
4 3
128 128
jpg
jpeg
12 3 8 5 4 11 7 1 9 6 10 2

The first line is a character string.
the next two lines are integers separated by a tab.
The next two lines are strings.
The last line are integers separated by spaces.

I have the following so far, but it looks like it only reads one string from the line at a time and if it encounters the integers, it may crash since it was expecting a string.:

Code:
FILE  *INFILE;
gchar str [80];
     
INFILE = fopen (appState->fileName, "r");
    
     while(INFILE)
     {
          fscanf (INFILE, "%s", str);
Is there a way to do something like the istringstream? Thanks.