1
I am improving a code I made for a college job. A very simplified version of Akinator. Before I did everything in the main code, now I want to read the characters of a txt file. I already created the file and already filled with the options, only now I need to take specific lines from the file to print and manipulate the rest of the code. Follow what I’ve done.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
FILE *personagens;
personagens = fopen("personagens.txt", "r");
//fprintf(personagens,"Son Goku\n"); -> escrever no arquivo
char modpersonagens[100];
while(fgets(modpersonagens, 100, personagens) != NULL){
printf("%s", modpersonagens);
}
fclose(personagens);
return 0;
}
Your doubt is like reading several characters one for each line in the file?
– Isac
Yes, I want to put each character in a vector place, so I can manipulate them.
– Sidney Campos
The text file is formatted with word n, word n
– Sidney Campos