for some reason i get 45 iterations of i but 0 of k "#include <stdio.h> #include…
Jump to turn (11)
- 1for some reason i get 45 iterations of i but 0 of k "#include #include #include
- 2how did you fix it
- 3i started can you finish the exercise "Un fichier, votes.txt, contient les noms
- 4heres the output Nombre d'électeurs : 0 Nombre de votes valides : 0 Nombre de vo
- 5give me the full code and use " and '
- 6I basically want it to where it reads how many characters in candidateNames[cand
- 7Give me the full code and change all variable names
- 8SECOND one : ❷Écrivez un programme qui remplacez toutes les occurrences du mot x
- 9what does the program do
- 10Do an example with the folder MyFile and we change the word that with fun
- 11i run executable nothing happens
- User
for some reason i get 45 iterations of i but 0 of k "#include <stdio.h> #include <stdlib.h> #include <string.h>
int main(){ int i = 0, k = 0, j; FILE *Vote_file, *Results_file; char ch, Candidate_names[50][15], votes[50];
codeVote_file = fopen("Votes.txt", "r"); if(Vote_file == NULL){ printf("Error reading file"); return 1; } Results_file = fopen("Results.txt", "w"); if(Results_file == NULL){ printf("Error writing file"); return 1; } do{ ch = getc(Vote_file); if(ch >= '0' && ch <= '9') { ungetc(ch, Vote_file); fscanf(Vote_file, "%s", &votes[k]); k++; } else { ungetc(ch, Vote_file); fscanf(Vote_file, "%s", &Candidate_names[i]); i++; } }while(ch != EOF); printf("%d %d", k, i); for(j=0; j<i; j++){ fprintf(Results_file, "%s %s\n", Candidate_names[j], Candidate_names[j+1]); j++; } for(j=0; j<k; j++){ fprintf(Results_file, "%s ", votes[k]); } fclose(Vote_file); fclose(Results_file); return 0;