Originally Posted by
nonpuz
Here is your code, working and cleaned up, minus extra logic/variables etc:
Please note that this code will ONLY work (and will likely crash) if it is not given a golf.txt file in its current directory that is PERFECTLY formatted, meaning exactly like this:
Note that after each of the lines with 18 digist (not the first line with only one digit) there is a single TRAILING space, this is REQUIRED for it be read correctly.
The slightest mistake, such as 2 extra spaces at the end will result in a file that will not be parsed correctly with the code above.
That is why I mentioned the fgets method as its much more flexible with how the file appears, you could put all kinds of stuff to ignroe comments, extra spacing, etc...with fscanf it is a pain