I'm using the following code in order to order to split up a file into a linked list filled with words and several paragraphs. My question is that it seems that my while loop doesn't seem to be stopping at the end of the file. Is it possible that the file I am using does not an EOF tag or something?
Thanks for your help.Code:while(fgets(currentLine, 125, fptr) != 0){ if(currentLine[0] == '\0'){ currentPara->nextParagraph = malloc(sizeof(PARAGRAPHPTR)); currentPara = currentPara->nextParagraph; currentPara->start = malloc(sizeof(LISTNODEPTR)); currentWord = currentPara->start; currentWord->nextPtr = NULL; currentWord->length = 0; printf("After?"); printf("\n"); } else{ for( i =0; i <= 124 && testChar != 0; i++){ printf("%d %d ", currentWord->length, i); printf("\n"); testChar = currentLine[i]; printf("\n"); if(testChar >= 33 && testChar < 127){ printf("%c ", testChar); currentWord->data[currentWord->length] = testChar; currentWord->length++; } else{ currentWord->nextPtr = malloc(sizeof(LISTNODEPTR)); currentWord = currentWord->nextPtr; currentWord->nextPtr = NULL; currentWord->length = 0; } } } }



LinkBack URL
About LinkBacks


