#include <stdio.h>
void main(){
FILE *g;
int i;
char str[100];
g = fopen("graph_input.txt", "r");
while(!feof(g)){
fgets(str, 100, g);
printf("%s", str);
}
fclose(g);
}
This code gives the following output:
7
2 4
1 3 4 6
2 6
1 2 6 5
4
4 2 3 7
6
6
The graph_input.txt
file is:
7
2 4
1 3 4 6
2 6
1 2 6 5
4
4 2 3 7
6
MY QUESTION
Why is the output showing the last line twice (i.e. the number 6 is being printed twice)?