Reading In File With fscanf Question
For a project, I have to read in input from a file, but the tricky part is that each line could have one of four formats:
"char long char string int float"
"char long string"
"char long string int"
"char long string int float"
Would this fscanf statement work for reading in the format?
Also, I want to read in line by line so that I can process the variables before moving onto the next line. Is there an easy loop I can use with fscanf to do this?
fscanf(input,"%c %ld %s %d %f%[^\n]",&todo,&id,symbol,&quantity,&price);