Utiliser un tableau de structure dans une structure
Bonjour
J'ai un problème d'utilisation d'un tableau de structure dans une structure
Le code à la structure suivante
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| /////////////////////////////////////////////////////////////
//heap.h ///
////////////////////////////////////////////////////////////
typedef struct
{
int capacity;
int size;
node *tab;
}Heap;
typedef struct
{
int cle;
coord p;
}node; |
Code:
1 2 3 4 5 6 7
| /////////////////////////////////////////////////////////////
//Coord.h ///
////////////////////////////////////////////////////////////
typedef struct {
unsigned int x;
unsigned int y;
} Coord; |
J'aimerais pouvoir accéder à mon tableau dans ma structure en tapant
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| /////////////////////////////////////////////////////////////
//main.c ///
////////////////////////////////////////////////////////////
#include <stdio.h>
#include "heap.h"
#include "Coord.h "
int main()
{
Heap *tas= malloc(sizeof(struct Heap));
tas->tab= malloc(30 *sizeof(Coord));
tas->tab[1].cle=2; // Voici ce qui plante et je comprends pas pourquoi.
tas->tab[1].p.x=3; // La aussi;
} |
Pourriez vous m'aidez ?