The file ends.txt has two columns, the first one corresponds to the last ending of a number and the second one to the number of times a finished number has appeared in it. The objective of the program is to show the ending that has appeared more times and how many times it has appeared but when executing the two values both the termination and the number of times it has appeared give me 0. Help pls.
#include <stdio.h>
int main() {
int num[10], veces[10], i, x, y = 0;
FILE *f1;
f1 = fopen("termina.txt", "r");
if (f1 == NULL) {
printf("Error al abrir el archivo");
return -1;
} else {
for(i = 0; i <= 9; i++) {
fscanf(f1,"%d %d", &num[i], &veces[i]);
if (veces[i] > y) {
veces[i] = y;
num[i] = x;
}
}
fclose(f1);
printf("Terminacion que mas veces ha aparecido: %d (%d veces)", x, y);
}
/*El archivo de texto termina.txt contiene lo siguiente:
0 728
1 732
2 736
3 697
4 738
5 749
6 705
7 732
8 726
9 724
*/
return 0;
}