Why do you put buildTrie in an endless while loop???
while(1) will loop forever !!
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
Test for an end of file condition.
Use something like while(!feof(inputfile))
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
Test for an end of file condition.
Use something like while(!feof(inputfile))
Bad idea, feof() shouldn't be use as the exit control of a loop. Read on .
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
OK Aia I know fgets gets NULL when getting something past eof, but I was concentrating on the infinity of the while loop first.
But anyway, thanks for reminding me!
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
Well i need to run fgets to get the pointer to the char array, i need to run this until the end of file... how would that while loop look like? Yes I am aware of while true... but I assumed if there was an error it would just break.
Hopefully, your assumption has been adjusted to go more in accordance with reality. As you have seen while(1) will not stop if nothing tells it to stop.
while( fgets(line, MAXLENGTH, inputfile) ) {
printf("HELP I'M IN A WHILE LOOP.\n");
buildTrie(nodeStart, inputfile);
}
Might work.
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
i have also problem in loop,do loop and while loop.can some suggest me about this three loops ?
You'll receive a better treatment if you create your own thread, post the pertinent portion of the code you are having problems with, and last but not least, you read, get aware, and follow the rules of the forum.
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218