Hi all!
The third loop in this code always runs one time, thus it just check the first "pword". I've no idea why....
thanks in advance for help
Code:
struct node* Build(struct node* head)
{
p = head->next;
while(p->next)
{
p=p->next;
}
pword=strtok(buf, "\n#");
while(pword)
{
n=malloc(sizeof(struct node));
char array1[strlen(pword)];
p->word=malloc(strlen(pword));
strcpy(array1, pword);
strcpy(p->word, pword);
pword=strtok(NULL, "\n#");
p->next=n;
p=n;
}
pword=strtok(buf, " \n.,#()");
char array2[strlen(askWord)];
strcpy(array2, askWord);
while(pword)
{
char array1[strlen(pword)];
strcpy(array1, pword);
if(strcmp(array1, array2)==0)
{
save=1;
}
pword=strtok(NULL, " \n.,#()");
}
return head;
}