1
wanted a program that counts how many times it was executed through a txt file that quarda this value, but what happens is that it never leaves 1, someone has an idea of what I did wrong?
#include <stdio.h>
int main() {
int numero_de_execucoes;
FILE *total;
numero_de_execucoes = 0;
total = fopen("total.txt", "w+");
if(total){
while(!feof(total)){
fscanf(total , "%d", &numero_de_execucoes);//lendo o ultimo numero_de_execucoes
}
}
else{
printf("ERRO");
}
numero_de_execucoes += 1;//incrementando + 1
fprintf(total, "%d", numero_de_execucoes);//escrevendo no arquivo o
//numero_de_execucoes atual
fclose(total);
printf("%d",numero_de_execucoes);//saida
}