Is there a C function that can set deliminators?I'm trying to read in a string token at a time from a file that is separated by space.
Is there a C function that can set deliminators?I'm trying to read in a string token at a time from a file that is separated by space.
There is a standard function strtok() which does this (allowing you to choose which characters to use as delimiters), but it has several serious drawbacks.
A better method might be to read single characters at a time from the file, using fgetc(), and store them in a buffer. Continue to do this until you reach a delimiter character, at which point you are done with one token and can begin the next one. Make sure that if there is more than one delimiter character in a row, that you consume all of them, so that you don't get bogus characters at the beginning of the next token.
When the eagles are silent, the parrots begin to jabber. ~Winston Churchill