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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
const gchar *sText;
FILE *f;
char type[255] ="";
float manger;
float dormir;
float etude;
float douche;
float muscu;
float asso;
manger=0;
asso=0;
etude=0;
muscu=0;
dormir=0;
douche=0;
f = fopen("cache/manger.txt","r");
if(f != NULL) {
fscanf(f, "%1.6f", &manger);
fclose(f);
}
else {
/* échec à l'ouverture */
perror("cache/manger.txt");
}
f = fopen("cache/asso.txt","r");
if(f != NULL) {
fscanf(f, "%1.6f", &asso);
fclose(f);
}
else {
/* échec à l'ouverture */
perror("cache/asso.txt");
}
f = fopen("cache/etude.txt","r");
if(f != NULL) {
fscanf(f, "%1.6f", &etude);
fclose(f);
}
else {
/* échec à l'ouverture */
perror("cache/etude.txt");
}
f = fopen("cache/muscu.txt","r");
if(f != NULL) {
fscanf(f, "%1.6f", &muscu);
fclose(f);
}
else {
/* échec à l'ouverture */
perror("cache/muscu.txt");
}
f = fopen("cache/dormir.txt","r");
if(f != NULL) {
fscanf(f, "%1.6f", &dormir);
fclose(f);
}
else {
/* échec à l'ouverture */
perror("cache/dormir.txt");
}
f = fopen("cache/douche.txt","r");
if(f != NULL) {
fscanf(f, "%1.6f", &douche);
fclose(f);
}
else {
/* échec à l'ouverture */
perror("cache/douche.txt");
}
sprintf(type,"save/%s.txt",sText);
f = fopen(type, "w+");
if(f != NULL) {
fprintf(f,"%1.6f\n%1.6f\n%1.6f\n%1.6f\n%1.6f\n%1.6f",manger,asso,muscu,etude,dormir,douche);
fclose(f);
}
else {
/* échec à l'ouverture */
perror("save/%s.txt");
}
} |
Partager