CodesC/TP5/fileread.c

24 lines
398 B
C
Raw Normal View History

2021-10-21 09:49:39 +00:00
#include <stdio.h>
int main () {
float a = 1.;
int b = 1 ;
2021-10-21 10:47:20 +00:00
FILE *point = fopen("data.dat","r"); // ouverture file "r" lecture
2021-10-21 09:49:39 +00:00
2021-10-21 10:47:20 +00:00
// test necessaire pour ouverture en lecture
if(point==NULL) {
puts("Echec de l'ouverture. Fin du programme.");
return 0;
}
2021-10-21 09:49:39 +00:00
2021-10-21 10:47:20 +00:00
fscanf(point,"%f %d \n",&a,&b); // lecture file
2021-10-21 09:49:39 +00:00
2021-10-21 10:47:20 +00:00
printf("%f %d \n",a,b); // print
fclose(point); // fermeture file
2021-10-21 09:49:39 +00:00
}