1
I ran that csv:
1;0
2;0
2;0
2;0
2;1
2;2
2;2
2;2
2;2
2;3
...
How to get from this file the first number of each line to increment it?
And there’s like the first line not to be skipped?
int gerarRelatorioHash(int colisoes) {
FILE *pont_arq;
pont_arq = fopen("relatorio.csv", "r+");
if(pont_arq == NULL) {
printf("Erro na abertura do arquivo!");
return 1;
}
int qtd;
fscanf(pont_arq, "%d", &qtd);
qtd++;
fseek(pont_arq, 0, SEEK_END);\
fprintf(pont_arq, "\n%d;%d", qtd,colisoes);
fclose(pont_arq);
printf("Dados gravados com sucesso!\n");
return 0;
}
The idea that the qtd
be an accountant to whom every line he jumps he makes a qtd++
and the second parameter is what was passed.
An example of how it should have turned out:
1;0
2;0
3;0
4;0
5;1
6;2
7;2
8;2
9;2
10;3
....
You could edit your question and put the example of your file with more lines to be clearer?
– Rogério Dec