What function to use in C to read file, line by line, and on each line contains different data types?
What function to use in C to read file, line by line, and on each line contains different data types?
To read the file you can use fgets
:
#define N 10000
[...]
FILE *arquivo;
arquivo=fopen("lugar.txt","r");
if(arquivo == NULL)
printf("Erro, nao foi possivel abrir o arquivo\n");
else{
while (fgets(linha, sizeof linha, arq3)) {
//e se quiser escrever na tela na tela
printf("%s",linha);
}
fclose(arquivo);
}