I generated this csv:
1;0
2;0
2;0
2;0
2;1
2;2
2;2
2;2
2;2
2;3
...
How do I get the first number of each line to increment it?
And how can the first line not 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 qtd
is a counter to which each line that it skips it makes a qtd++
and the second parameter is what was passed.
Example of how it should have been:
1;0
2;0
3;0
4;0
5;1
6;2
7;2
8;2
9;2
10;3
....