While fscanf
might not be the best function to use in this case, formally one can still be use it to grab the string that ends with ;
by using the following format specifier
fscanf(fileptr, "%[^;];%i",
albums[size].tracks[track].name,
&albums[size].tracks[track].length);
This will require the input file to adhere to very strict format requirements though. Note also that if your albums[size].tracks[track].length
is an int
object, then &
operator is required before albums[size].tracks[track].length
. When %i
format specifier is used in fscanf
it requies a pointer to int
as argument.
Also, your printf
does not look right. It should be
printf("Track number %i : %s", track, albums[size].tracks[track].name);
That &
before albums[size].tracks[track].name
is not supposed to be there.