the function is supposed to construct a linked list out of
the inputed word
i completed as far as i could.
why i need temp and temp2
??
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct wordStruct{
char string[256];
struct wordStruct *next;
} wordStruct;
wordStruct * wordAlloc(char *str){
wordStruct *temp;
temp = (wordStruct *)malloc(sizeof(wordStruct));
temp->next=NULL;
strcpy(temp->string,str);
return temp;
}
wordStruct *insert( wordStruct *head, char *st){
wordStruct* temp, *temp2;
if(head == NULL) return wordAlloc(st);
if(?? 6 ??|| (?? 7 ?? && ?? 8 ??)){
temp = ?? 9 ??;
?? 10 ??;
return temp;
}
for(temp=head; temp->next ; temp = temp -> next){
if(?? 11 ??)break;
if( ?? 12 ??&& ?? 13 ??)break;
}
temp2 = temp->next;
?? 14 ??;
?? 15 ??;
return head;
}
void main(){
char word[256];
wordStruct *list = NULL;
while(scanf("%s", word)==1)
list = insert(list, word);
. . . .
}