C/C++: Lire un fichier avec ‘fscanf()’

Author:


Download

/*
#include 
int fscanf ( FILE * restrict fichier , const char * restrict format , ... );
*/  

  #include 
  #include 

  int main(void)
  {
    FILE *fichier;
    int i;

    if((fichier=fopen("test.txt.", "wb"))==NULL) {
      printf("Impossible d'ouvrir le fichier.");
      exit(1);
    }

    char str[80];
    double d;

    i= fscanf(fichier, "%s%lf", str, &d);

    fclose(fichier);

	return 0;
  }

Leave a Reply

Your email address will not be published. Required fields are marked *