Potential memory issues with strtok:
Since one of the suggested solutions uses
strtok, unfortunately it doesn't point out a potential memory issue (though it claims to be memory efficient). When using
strtok according to the manual, the:
Note that only the first call to strtok uses the string argument. Every subsequent call to strtok only needs the token to use, as it keeps track of where it is in the current string.
It does this by loading the file into memory. If you're using large files, you need to flush them if you're done looping through the file.