Open su8 opened 6 years ago
The solution which I would like to propose is to read the file content at once with malloc, and split the string into tokens. This way no matter how long a single line could be, it will be numbered properly. I will use this strategy to contribute around 10 programs later on next week.
Shadowing the function read() isn't pretty.
Also no format specifier is used to tell to the program to scan until the newline character is met.
edit: I've mistaken f/scanf with fgets