The main task for my code is to take out data from outside files and then ascribe a number at the beginning. The problem is that the code below works just fine.
#include <stdio.h>
int main(void) {
char name[20], surname[30], group[2];
puts("Now i download data from file");
int n = 1, number;
while (!feof(stdin)) {
scanf ("%s %s %d %s", name, surname, &number, group);
printf("%d. %s | %s | %d | %s", n, name, surname, number, group);
}
return 0;
}
But when I change the position of one line it sets the value of n
to 0 and doesn't rise.
#include <stdio.h>
int main(void) {
int n = 1, number;
char name[20], surname[30], group[2];
puts("Now I download data from file");
while (!feof(stdin)) {
scanf ("%s %s %d %s", name, surname, &number, group);
printf("%d. %s | %s | %d | %s", n, name, surname, number, group);
}
return 0;
}