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>
struct maillon
{
int val;
struct maillon *p_next;
};
int main(void)
{
struct maillon *p_head;
/* premier */
p_head = malloc (sizeof *p_head);
/* attention, malloc() peut echouer... */
p_head->p_next = NULL;
p_head->val = 123;
/* deuxième */
p_head->p_next = malloc (sizeof *p_head);
p_head->p_next->p_next = NULL;
p_head->p_next->val = 456;
/* evidemment, si il y a 200 maillons, on ne va pas faire ca.
Il va donc falloir creer des fonctions qui font le travail
automatiquement... */
/* liberation de la memoire ... */
return 0;
} |
Partager