Function to read file in C [closed]

1

What function to use in C to read file, line by line, and on each line contains different data types?

    
asked by anonymous 31.05.2018 / 18:39

2 answers

2

Generally what you need is some variation of fscanf() . You may also use vfscanf() .

    
31.05.2018 / 18:44
-1

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);
      }
    
31.05.2018 / 20:40