#include <stdio.h>
#include <stdlib.h>
#define SIZE 200
int main() {
FILE *input = fopen("word_list_final.txt", "r");
char buffer[SIZE];
int counter = 0;
if (input == NULL) {
printf("Error! Could not open file\n");
exit(-1);
}
while (fscanf(input, "%s\n", buffer) != EOF) {
counter++;
}
fclose(input);
printf("%d\n", counter);
return 0;
}
After executing, program prints correct result and mentioned message. (File, I'm reading from, contains one word per line)
Outputs:
89937042 *** stack smashing detected ***: terminated Aborted (core dumped)
How to get rid of error message?