Hey... I'm very much a newbie to C and was hoping someone might be able to offer some help or just point me in the right direction, thanks. ^_^.
Anyway, my program is supposed to read in a line from stdin and then break the line into words. It does this okay, but I don't know how I could modify it so that it will only continue assigning values to the variables *if* there are values to assign.
Like, the current code (where 'search' is a space and 'end' is a newline character) is:
first = strtok(s, search);
second = strtok(NULL,search);
third = strtok(NULL, search);
fourth = strtok(NULL,end);
This is fine if the input is four words as expected, but what I was wondering if someone could suggest some way to kind of check, like, if there are more words in the string. I'm more used to working in Java so I must admit my understanding of strtok is not very strong in C; there may be some much better way of approaching the problem.
Anyway, I guess it's a very simple question so hopefully it can be cleared up easily, thanks.
-Leto ^_^.