so i have a funtion to read words and put thm all in lowercas leteering.how do i insert the wordsv into a link list ?i have declared the link list and wrote a function to add the words in place.i jus cant figure out how to link the two so when the word is "lower cased" i need to add it in place into a link list
//code for gettin word from file
and this is myaddinplace functions which supposed to add wordsread into a link list in ascending order.Code:int getword(FILE*in,char string[]){ char ch; int n=0; //read over blank space while(!isalpha(ch=getc(in)) && ch!='\0') if(ch==EOF) return 0; string[n++]=tolower(ch); while(isalpha(ch=getc(in)) && ch!='\0') if(n<20)string[n++]=tolower(ch); string[n]='\0'; return 1; }
im not sure how to implement themCode:Nodeptr addinplace(Nodeptr top,char string[]){ Nodeptr str,curr,prev,makenode(char[]); str=makenode(string); prev=NULL; curr=top; while(curr!=NULL && strcmp(curr->word,string)<0){ prev=curr; curr=curr->next; } if(prev==NULL){ str->next=top; return str; } str->next=curr; prev->next=str; return top; }



LinkBack URL
About LinkBacks


