Read formatted numbers from a txt file
hi all, i'm working on a c program that would sort an array of numbers, and then compare with another text file produced by a sorting program to see if they match.
Before I dealt with numbers that are in one column, so I just used the code below and it did the job of getting the numbers into an array.
Now I have to deal with numbers that has formatting. There are now two columns of numbers instead of just one. First column is random numbers, unsorted, and * marks the end of each group. 2nd column is sorted, and # marks the end of the group. Either column one or two could be empty. For example,
while ( !feof(streamSorted ) )
fscanf_s( streamSorted, "%d", &sorted[sortedSize] );
I will need to load all of the unsorted groups into an array, and the sorted groups into another one.
Someone suggested to use fgets() but I don’t exactly see how it can do the job?
Can someone please point it out? Thanks so much…