Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int numero_de_execucoes;
  5. FILE *total;
  6. numero_de_execucoes = 0;
  7. total = fopen("total.txt", "w+");
  8.  
  9. if(total){
  10. while(!feof(total)){
  11. fscanf(total , "%d", &numero_de_execucoes);//lendo o ultimo numero_de_execucoes
  12. }
  13. }
  14. else{
  15. printf("ERRO");
  16. }
  17.  
  18. numero_de_execucoes += 1;//incrementando + 1
  19.  
  20.  
  21. fprintf(total, "%d", numero_de_execucoes);//escrevendo no arquivo o
  22. //numero_de_execucoes atual
  23.  
  24. fclose(total);
  25. printf("%d",numero_de_execucoes);//saida
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement