Bonjour à tous je viens vers vous avec un petit problème.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
#ifndef Fichiergph
#define Fichiergph
typedef struct
{
        char name[50];
        int L; 
        float value[2][10000];
}Graph;        
void NameFich(char name[])
 
{
     printf("Name for create Graph file : \n", name);
     scanf("%s", name);
     strcat(name, ".gf");
}
 
void ScriptGraph(Graph datagraph)
{
     char name[30];
     FILE *s;
     int i, z;
     int n = 0;
 
     NameFich(name);
 
     s = fopen(name, "w");
 
     fwrite(&datagraph.L, sizeof(int), 1, s);
 
     for(z = 0; z < datagraph.L; z++)
     {
           for(i = 0; i<2; i++)
           {     
                 fwrite(&datagraph.value[i][z], sizeof(float), 1, s);
           }
     }
 
 
     for(i = 0; i < datagraph.L/10; i += 1)
     {
        printf("Value %.3f : %.2f\n", datagraph.value[0][i], datagraph.value[1][i]);
     }     
     fclose(s);  
}
 
Graph ReadGraph()
{
     char name[30];
     FILE *e;
     Graph datagraph;
     int i, z;
 
     NameFich(name);
 
     e = fopen(name, "r");
 
     fread(&datagraph.L, sizeof(int), 1, e);
 
     for(z = 0; z < datagraph.L; z++)
     {
           for(i = 0; i<2; i++)
           {                 
                 fread(&datagraph.value[i][z], sizeof(float), 1, e);
           }
     }
 
     fclose(e);
 
     printf("\n\n%d\n\n", datagraph.L);
 
     for(i = 0; i < datagraph.L/10; i += 1)
     {
           printf("Value %.3f : %.2f\n", datagraph.value[0][i], datagraph.value[1][i]);
     }     
 
     return datagraph;
}     
 
#endif
Voila lorsque je crée un fichier grâce à la fonction Scriptgraph tout vas bien.
Mais lorsque je relis ce même fichier avec readgraph il rentre les valur au fur et à mesure dans le tableau mais à partir de i = 880 (je crois) la fonction rentre uniquement la valeur 0.00 pour toutes les cases de mon tableau datagraph.value[x][y] suivantes.

Dsl pour le temps que je vous prends.
Cordialement Aurélien