Probleme dans la procedure depilment C
Résolu
ghostdz
-
ghostdz -
ghostdz -
Bonjour,
typedef struct pile
{
int data;
struct pile *suiv;
}stack;
void depiler (int *y,stack **d)
{
stack *tmp2;
*y= d->data;
tmp2=d;
d=d->suiv;
free (tmp2);
}
l erreur ici
*y= d->data;
d=d->suiv;
msg erreur:
error: request for member 'data' in something not a structure or union|
error: request for member 'suiv' in something not a structure or union|
comment reglè ce probleme ?
et merci d'avance
typedef struct pile
{
int data;
struct pile *suiv;
}stack;
void depiler (int *y,stack **d)
{
stack *tmp2;
*y= d->data;
tmp2=d;
d=d->suiv;
free (tmp2);
}
l erreur ici
*y= d->data;
d=d->suiv;
msg erreur:
error: request for member 'data' in something not a structure or union|
error: request for member 'suiv' in something not a structure or union|
comment reglè ce probleme ?
et merci d'avance
A voir également:
- Probleme dans la procedure depilment C
- Le point d'entrée de procédure est introuvable dans la bibliothèque de liens dynamiques ✓ - Forum Logiciels
- Procédure de frigo vide ✓ - Forum Consommation & Internet
- Le point d'entrée de procédure eventsetinformation est introuvable advapi32.dll - Forum Windows
- Le point d'entrée de procédure iswow64process2 est introuvable - Forum Windows
- Point d'entrée de procédure introuvable ✓ - Forum Logiciels
2 réponses
structure
typedef struct pile
{
int data;
struct pile *suiv;
}stack;
l'initialisation dans le pgm principale
typedef struct pile
{
int data;
struct pile *suiv;
}stack;
l'initialisation dans le pgm principale
code source complet
#include<stdio.h>
#include<malloc.h>
typedef struct pile
{
int data;
struct pile *suiv;
}stack;
int i;stack *tmp=NULL;
void empiler(int x,stack ** p)
{
tmp=(stack*)malloc(sizeof(stack));
tmp->data=x;
tmp->suiv=*p;
*p=tmp;
}
void depiler (int *y,stack **d)
{
stack *tmp2;
*y= d->data;
tmp2=d;
d=d->suiv;
free (tmp2);
}
void afficher (stack **p)
{
tmp=p;
while (tmp!=NULL)
{
printf("%d",tmp->data);
tmp=tmp->suiv;
}
}
int main()
{
stack *pil=NULL;int z;
empiler(1,&pil);
empiler(2,&pil);
empiler(3,&pil);
empiler(4,&pil);
empiler(5,&pil);
//depiler (&z,pil);
afficher(pil);
//printf("/n%d",n);
return 0;
}
#include<stdio.h>
#include<malloc.h>
typedef struct pile
{
int data;
struct pile *suiv;
}stack;
int i;stack *tmp=NULL;
void empiler(int x,stack ** p)
{
tmp=(stack*)malloc(sizeof(stack));
tmp->data=x;
tmp->suiv=*p;
*p=tmp;
}
void depiler (int *y,stack **d)
{
stack *tmp2;
*y= d->data;
tmp2=d;
d=d->suiv;
free (tmp2);
}
void afficher (stack **p)
{
tmp=p;
while (tmp!=NULL)
{
printf("%d",tmp->data);
tmp=tmp->suiv;
}
}
int main()
{
stack *pil=NULL;int z;
empiler(1,&pil);
empiler(2,&pil);
empiler(3,&pil);
empiler(4,&pil);
empiler(5,&pil);
//depiler (&z,pil);
afficher(pil);
//printf("/n%d",n);
return 0;
}