1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| #include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
void afficher(char*,int);
int main() {
static FILE *ptr;
int ligne[1];
int colonne[1];
double flottant;
int temp;
char ligneFichier[8] = " ";
char* carac;
char* cptr;
afficher(ligneFichier,8);
ptr = fopen("fichier.bin","rb");
if(ptr==NULL)
exit(0);
temp = fread(ligne, sizeof(int),1,ptr);
if(temp<=0)
exit(0);
temp = fread(colonne, sizeof(int),1,ptr);
if(temp<=0)
exit(0);
temp = fread(&flottantsizeof(flottant),1,ptr);
if(temp<=0)
exit(0);
/*
temp = fread(&ligneFichier[0],sizeof(char),1,ptr);
if(temp<=0)
exit(0);
temp = fread(&ligneFichier[1],sizeof(char),1,ptr);
if(temp<=0)
exit(0);
temp = fread(&ligneFichier[2],sizeof(char),1,ptr);
if(temp<=0)
exit(0);
temp = fread(&ligneFichier[3],sizeof(char),1,ptr);
if(temp<=0)
exit(0);
temp = fread(&ligneFichier[4],sizeof(char),1,ptr);
if(temp<=0)
exit(0);
temp = fread(&ligneFichier[5],sizeof(char),1,ptr);
if(temp<=0)
exit(0);
temp = fread(&ligneFichier[6],sizeof(char),1,ptr);
if(temp<=0)
exit(0);
temp = fread(&ligneFichier[7],sizeof(char),1,ptr);
if(temp<=0)
exit(0);
afficher(ligneFichier,8);
*/
flottant = strtod(ligneFichier,&cptr);
fclose(ptr);
/*
printf("ligne=%d colonne=%d chaine=%s tailleChaine=%d double=%f\n ligne=%s\n",ligne[0],colonne[0],carac,sizeof(carac),flottant,ligneFichier);
*/
printf("ligne=%d colonne=%d double=%f\n ligne=%s\n",ligne[0],colonne[0],flottant,ligneFichier);
return 0;
}
void afficher(char* chaine,int taille) {
int i;
for(i=0;i<taille;i++) {
printf("%d=< %c >\n",i,chaine[i]);
}
} |
Partager