| 12
 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
 
 |  
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int k,step;
    double value;
    step=2;
    value=100.0;
    FILE *fp=NULL;
    int first_calculous=0;
    void READ();
 
 
    if (first_calculous==0)
    {
 
        READ(step,value,fp);
 
        fprintf(stderr,"starting the calculous with : step=%d value=%e \n", step,value);
    }
 
    for (k=1;k<=10;k++)
    {
        fprintf(stderr,"Increment %d\n",k);
        step++;
        value*=3;;
 
        if (k==4 && first_calculous==1)
        {
            fp=fopen("sauvegarde","w");
            fwrite(&step,sizeof(int),1,fp);
            fwrite(&value,sizeof(double),1,fp);
            fclose (fp);
            //exit(-1);
 
        }
 
    }
    printf("Hello world!\n");
    return 0;
}
 
void READ(int step,double value,FILE *fp)
{
       fp=fopen("sauvegarde","r");
        fread(&step,sizeof(int),1,fp);
        fread(&value,sizeof(double),1,fp);
        fclose (fp);
return;
} | 
Partager