hi everyone,
for some reason im getting a segfault when i run this code to count how many words there are in the file...also if theres a better way to do it ..please let me know thanks...
thanks for any help
Code:int fileLength(FILE *file) { int file_len=0; char line[LINESIZE]; char *linePtr = line; while (fgets(line, LINESIZE, file) != NULL) { while(*linePtr != "\0") { /* move through non words */ while((isspace(*linePtr)) || (ispunct(*linePtr))) linePtr++; /* reached a word */ file_len++; linePtr++; /* move off the word */ while(isalpha(*linePtr)) linePtr++; } } return file_len; }