Hey, i have a question.
I am using scanf to read in a paragraph from the keyboard and break it up into words.
I am close to doing this but I cant figure out how to make my loop stop.
When there are no more words, I would like my loop to stop, but I dont know how to check for that.
Here is what I ahve so far, any help would be appreciated.
How do you check to see if there are any more words left?Code:#include <stdio.h>
#include <string.h>
#define MAX_SIZE 16
int main(void)
{
/* char array to hold each word with a max word size of 15 */
char words[MAX_SIZE];
printf("Enter a line of text: ");
/* this loop prints each word one after the other from left to right */
while(scanf("%s", words)!= 0) {
printf("%s\n", words);
/*if there are no more words,
end loop*/
}
}
Also how can I equal the value of scanf("%s", words) to 1 so the loop stops.
Thanks

