Bonjour.
Voici mon code:
Normalement f->nodes = 100; mais là ça me dit que ça vaut 0. Une idée pourquoi?
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 int main(int argc, char *argv[]) { Heap* f; createHeap(f); printf("f has n= %i nodes\n",f->nodes); return 0; } //this function creates a heap: memory allocation and data fields are initialised. Heap* createHeap(Heap* f){ f = (Heap*)malloc(sizeof(Heap*)); initialise(f); return f; } void initialise(Heap* f){ f->nodes = 100; f->min = NULL; }
ps: je tiens a préciser que la signature de la fonction est imposée. sinon j'aurais fait
[code]
Bonjour.
Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 Heap* createHeap(){ Heap* f = (Heap*)malloc(sizeof(Heap*)); initialise(f); return f; }
Partager