I have a file with Space Separated Values Eg:
6028 5 6
9813 2 10
10249 7 8
10478 8 8
10479 3 2
10516 6 3
10519 9 10
10525 3 7
10606 6 1
10611 6 9
10632 1 6
10638 9 4
And I can't retrieve them to variables using the following code:
#include <stdio.h>
#include <stdlib.h>
void ReadVector(int V[], int *N);
int CalcularAprovados(int V[], int N);
void ReadVector(int V[], int *N){
FILE *f;
f = fopen("dados4.txt", "r");
if (f == NULL){
printf("Error");
}
int nAluno, nTeste, nTrab;
while(fscanf(f, "%d%d%d\n", &nAluno, &nTeste, &nTrab) == EOF){
//fscanf(f, "%d %d %d", &nAluno, &nTeste, &nTrab);
printf("%d %d %d\n", nAluno, nTeste, nTrab);
}
fclose(f);
}
int main(){
int *V, N=0;
ReadVector(&V[0], &N);
}
And
int nAluno, nTeste, nTrab;
while(fscanf(f, "%d%d%d\n", &nAluno, &nTeste, &nTrab) == EOF){
//fscanf(f, "%d %d %d", &nAluno, &nTeste, &nTrab);
printf("%d %d %d\n", nAluno, nTeste, nTrab);
}
doesn't work I want this to update the variables content until it reaches the end of file.