[C/C++]probleme avec les pile

Fermé
mariusapo Messages postés 37 Date d'inscription mercredi 14 janvier 2004 Statut Membre Dernière intervention 30 septembre 2011 - 14 mars 2010 à 17:06
Bonjour, dites moi ce qui ne marche pas dans ce code,
c'est l'implémentation d'une structure de pile en c. J'ai beau faire, je comprends pas l'eereur, alors HELP PLEASE !
#include<stdio.h>
#include<conio.h>
#include<malloc.h>

main() {
  struct Tetepile {
           int cle;
           struct Tetepile *pred;
         }tete, *noeud;
  int i;
  tete.cle=-1;
  tete.pred=NULL;
  //noeud=&tete;
  struct Tetepile tmp;

  /*REMPLISSAGE DE PILE AVEC 10 ELEMENTS*/
  for(i=0;i<10;i++) {
    
    noeud = (struct Tetepile *)malloc(sizeof(struct Tetepile));
    noeud->pred = &tete;
    noeud->cle = i;
    tete = *noeud;
    printf("%d",tete.cle);
  };
  getch();
  /*AFFICHAGE DE SES ELEMENTS, JUSTE POUR TESTER*/
  printf("%d \t",tete.pred->cle);
  noeud = noeud->pred;
  printf("%d \t",tete.pred->cle);
  getch();
}