Truc de pointeur SVP aide mw C
Résolu
kribac
Messages postés
148
Statut
Membre
-
kribac Messages postés 148 Statut Membre -
kribac Messages postés 148 Statut Membre -
bonjour a ts bon voila ma structure
typedef struct telephone {
int n1;
int n2;
char c[20];
int ind;
int occupe;
struct telephone * sv;
}tel;
voila ma fonction ajouter une structure
void ajouter(liste*l,int a,int b,char k, int i) {
liste p; p=*l;
liste nouveau=(liste)malloc(sizeof(tel));
nouveau->n1=a;
nouveau->n2=b;
nouveau->ind=i;
nouveau->occupe=1;
strcpy(nouveau->c,k); // erreur ici passing arg 2 of 'strcpy' makes pointer from integer
without a cast
nouveau->sv=NULL;
if(*l==NULL)*l=nouveau;
else { while(p->sv!=NULL) p=p->sv;
p->sv=nouveau;
}
}
int n,N1,N2;
char p[20];
liste pol1=NULL;
printf("%2d -N1=",i+1);
scanf("%d",&N1);
printf(" -c1c2c3=");
scanf("%s",p);
printf(" -N2=",i+1);
scanf("%d",&N2);
ajouter(&pol1,N1,N2,p,5); // erreur ici passing arg 4 of 'ajouter' makes integer from pointer
without a cast
bon le prog marche tr bien dans le cas ou j'enléve "char k" et "p"
donc j 1 problem avec ce K é ça dans l'appel donc je savoir comment l'appeler ds la fonction ?? est ce que ajouter(&pol1,N1,N2,&p,5); ??? ou bien dans la fonction ajouter(liste*l,int a,int b,char * k, int i) ??? ché plu aidé mw
typedef struct telephone {
int n1;
int n2;
char c[20];
int ind;
int occupe;
struct telephone * sv;
}tel;
voila ma fonction ajouter une structure
void ajouter(liste*l,int a,int b,char k, int i) {
liste p; p=*l;
liste nouveau=(liste)malloc(sizeof(tel));
nouveau->n1=a;
nouveau->n2=b;
nouveau->ind=i;
nouveau->occupe=1;
strcpy(nouveau->c,k); // erreur ici passing arg 2 of 'strcpy' makes pointer from integer
without a cast
nouveau->sv=NULL;
if(*l==NULL)*l=nouveau;
else { while(p->sv!=NULL) p=p->sv;
p->sv=nouveau;
}
}
int n,N1,N2;
char p[20];
liste pol1=NULL;
printf("%2d -N1=",i+1);
scanf("%d",&N1);
printf(" -c1c2c3=");
scanf("%s",p);
printf(" -N2=",i+1);
scanf("%d",&N2);
ajouter(&pol1,N1,N2,p,5); // erreur ici passing arg 4 of 'ajouter' makes integer from pointer
without a cast
bon le prog marche tr bien dans le cas ou j'enléve "char k" et "p"
donc j 1 problem avec ce K é ça dans l'appel donc je savoir comment l'appeler ds la fonction ?? est ce que ajouter(&pol1,N1,N2,&p,5); ??? ou bien dans la fonction ajouter(liste*l,int a,int b,char * k, int i) ??? ché plu aidé mw