I'm trying to get the last word from each line in a file using strtok(). I know how to step through each line in the file but I am having trouble getting the last word of the line.
The line looks like this:
so far I have this:Code:ROOM NAME: Room
The output:Code:char *token = strtok(line, " "); while (token != NULL) {printf("%s\n", token); token = strtok(NULL, " ");}
I'm printing out each word to see what I'm doing. Ultimately I would like to store the last word in a variable. I'm just not sure how to get the last word.Code:ROOM NAME: Room