hey im trying to read a sequence of strings from the user and store them in different nodes..my code reads the line and stores it as a whole sentence , how do i split the line into individual strings and store them into different nodes ? if i use strtok it only stores the first word and ignores the rest..please help!
Code:
getline(words)
p=(Node *) malloc(sizeof(Node));
strcpy(p->word,words);
p->next = head;
head = p;
Code:
char *getline( char *text)
{
if( fgets( word, 128, stdin ) == NULL ) return NULL;
if( ( temp = strchr( words, '\n' ) ) )
*temp = 0;
else while( getchar() != '\n' );
return words;
}