salut a tt

Voici le problème d'un grand débutant en C:
Je commence par créer un tableau dynamique pour implémente la structure de tas voila mon code
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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#include <stdio.h>
#include <stdlib.h>
 
 typedef struct Tas *PTasmax;
    typedef struct Commande * PCommande;
 
    typedef struct Commande
    {
            int unsigned NCommande;
            char DateCommande[11];
            int unsigned NumClient;
            char NomClient[25],PrenomClient[25];
            char AdresseClient[25];
            int unsigned QuantiteCommande;
            char etat;
 
    }Commande;
    typedef struct Tas
    {
            int ind;
            PCommande T;
    }Tas;
 
 
 
 
void AfficherTas(PTasmax T)
    {
            int i;
    for(i=0;i<=T->ind;i++)
            {
 
                    printf("\n  -------------------------------------------- ");
                    printf("\n |- Numero Commande : %u",T->T[i].NCommande);
                    printf("\n |- Quantite Commande : %u",T->T[i].QuantiteCommande);
                    printf("\n |- Date de Commande Client : %s ",T->T[i].DateCommande);
                    printf("\n |- Numero Client : %u ",T->T[i].NumClient );
                    printf("\n |- Nom Client : %s ",T->T[i].NomClient);
                    printf("\n |- Prenom Client : %s ",T->T[i].PrenomClient);
                    printf("\n |- Adress Client : %s ",T->T[i].AdresseClient);
                    printf("\n  -------------------------------------------- ");
            }
    }
 
 
 
int Pere(int Pos,PTasmax Tasmax){
div_t temp;
temp =  div(Pos,2);
if(Pos % 2 ==0)
{return ((temp.quot)-1);}
else
{return (temp.quot);}
}
 
int Qcommande(int Pos,PTasmax Tasmax){return Tasmax->T[Pos].QuantiteCommande;}
 
 
void  Echanger(int index1,int index2,PTasmax Tmax)
{
Commande c;
c = Tmax->T[index1];
Tmax->T[index1] = Tmax->T[index2];
Tmax->T[index2] = c;
}
 
void EntasserTmax(int i,PTasmax Tmax){
int g,d,m;
 
g = 2*i+1;
d = 2*i+2;
m = i;
 
if(g<=Tmax->ind && Qcommande(g,Tmax)>Qcommande(m,Tmax))
{
    m = g;
}
if(d<=Tmax->ind && Qcommande(d,Tmax)>Qcommande(m,Tmax))
{
    m = d;
}
if(m != i)
{
    Echanger(i,m,Tmax);
    EntasserTmax(m,Tmax);
}
 
}
 
 
 
 
 
 
 
 
 
void InsererTmax(Commande V,PTasmax Tasmax)
{
    int i,p;
   i = Tasmax->ind;
p = Pere(i,Tasmax);
while(i>0 && V.QuantiteCommande > Qcommande(p,Tasmax))
{
Tasmax->T[i] = Tasmax->T[p];
i = p;
p = Pere(i,Tasmax);
}
Tasmax->T[i] = V;
}
 
void ajoutetasmax(PTasmax Tasm){
 
     if(Tasm->T == NULL)
    {
    Tasm->ind = Tasm->ind+1;
 
    //Tasm->T = malloc(sizeof(Commande));
//T->T = realloc(T->T,1 * sizeof(Commande));
    Tasm->T = calloc(1,sizeof(Commande));
    }else
    {
Tasm->ind = Tasm->ind+1;
Tasm->T = realloc(Tasm->T,Tasm->ind+1 * sizeof(Commande));
    }
 
 
 
 
printf(" \n Entre Nom Client : %d ",Tasm->ind);
                    scanf("%s",&Tasm->T[Tasm->ind].NomClient);
            printf(" \n Entre Prenom Client : %d ",Tasm->ind);
                                    scanf("%s",&Tasm->T[Tasm->ind].PrenomClient);
									    printf("\n |- Numero Client : ");
  scanf("%u",&Tasm->T[Tasm->ind].NumClient);
 
  printf("\n |- Numero Commande : ");
  scanf("%u",&Tasm->T[Tasm->ind].NCommande);
     printf("\n |- Quantite Commande :");
  scanf("%u",&Tasm->T[Tasm->ind].QuantiteCommande);
    printf("\n |- Date de Commande Client : ");
  scanf("%s",&Tasm->T[Tasm->ind].DateCommande);
 
 
     printf("\n |- Adress Client : ");
  scanf("%s",&Tasm->T[Tasm->ind].AdresseClient);
 
 
 
}
 
 void ajouteT(PTasmax Tasm){
Commande V;
// SAISIE DE LA COMMANDE
printf(" \n Entre Nom Client : ");
scanf("%s",&V.NomClient);
 
printf(" \n Entre Prenom Client : ");
scanf("%s",&V.PrenomClient);
 
printf("\n |- Numero Client : ");
scanf("%u",&V.NumClient);
 
printf("\n |- Numero Commande : ");
scanf("%u",&V.NCommande);
 
printf("\n |- Quantite Commande :");
scanf("%u",&V.QuantiteCommande);
 
printf("\n |- Date de Commande Client : ");
scanf("%s",&V.DateCommande);
 
printf("\n |- Adress Client : ");
scanf("%s",&V.AdresseClient);
V.etat = 'c';
//FIN DE LA SAISIE
 
 
//IF
    if(Tasm->T == NULL)
    {
    Tasm->ind = Tasm->ind+1;
 
    //Tasm->T = malloc(1*sizeof(Commande));
//T->T = realloc(T->T,1 * sizeof(Commande));
    Tasm->T = calloc(1,sizeof(Commande));
    }else
    {
Tasm->ind = Tasm->ind+1;
Tasm->T = realloc(Tasm->T,Tasm->ind+1 * sizeof(Commande));
    }
//END IF
 
//INSERTION PAR LA PROCEDURE INSERERTMAX
InsererTmax(V,Tasm);
//FIN INSERTION
    }
 
void PagePrincipale();
 
int main()
{
PTasmax Tasm;
 
 
int i;
  Tasm = (PTasmax)malloc(sizeof(Tas));
            Tasm->T = NULL;
            Tasm->ind = -1;
 
 
 
 
ajouteT(Tasm);
ajouteT(Tasm);
ajouteT(Tasm);
AfficherTas(Tasm);
 
 
 
 
 
return 0;
 
}
 
 
 
 
 
 
void PagePrincipale()
{
    int j;
    system("cls");
		printf("|----------------------------------------------------------------------------|\n");
		printf("|[1]- Saisir d'une ou de plusieurs Commandes .                               |\n");
		printf("|[2]- Afficher les info de la commande qui contient la plus grande quantite .|\n");
		printf("|[3]- La Modification de la quantite commandee d'une commande .              |\n");
		printf("|[4]- Afficher le nombre de commandes en attente de traitement .             |\n");
		printf("|[5]- Afficher de la quantite totales des commandes en attente de traitement.|\n");
		printf("|[6]- Afficher de la liste des commandes .                                   |\n");
		printf("|[7]- Sortir Du Programme .                                                  |\n");
		printf("|----------------------------------------------------------------------------|\n");
		for(j=0;j<=7;j++){ printf("\n"); }
		printf("                         Programmer Par : Oussama Abdellah. \n");
}

alors si j’exécute ce code la il exécuté bien sans erreur sauf a la dernière commande le programme bloque


si j’exécute le code par une seule appel de la fonction d'insertion
le programme fonction bien

Aide moi SVP