l'allocation memoire array
bonsoir ,vous pouvez me dire pourquoi l'allocation de memoire echoue ???
Code:
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
| #include<stdlib.h>
#include<stdio.h>
#define max 10;
int main()
{
struct complexe
{
double re;
double im;
};
int i=0;
struct complexe *c;
// struct complexe tab[10];
struct complexe tab[10];
c=calloc(11,sizeof(struct complexe));
if(c==NULL);
{
fprintf(stderr,"allocation impossible\n");
exit(EXIT_FAILURE);
}
while(i<10)
{
tab[i].re=i*2;
tab[i].im=i*3;
i++;
}
for(i=0;i<10;i++)
{
printf("%lf %lf\n",tab[i],tab[i]);
}
} |