marcus81
13-06-2002, 10:54
Qualcuno potrebbe chiarirmi questo dubbio?
Dunque quando in c bisogna sempre usare il
doppio puntatore e perchè?
x esempio quando faccio l'inserimento in una lista o
in un albero perkè nn si può usare un puntatore normale?
faccio un esempio:
int insert(LISTA **head, SQUADRA buffer)
{
LISTA *paus,*punt;
if((paus=(LISTA *)malloc(sizeof(LISTA)))==NULL) return 0;
paus->etichetta=buffer;
if(*head==NULL){
paus->next=NULL;
*head=paus;
}
else{
punt=*head
while(punt->next!=NULL)
punt=punt->next;
paus->next=NULL;
punt->next=paus;
}
return 1;
questa procedura funziona bene se uso un puntatore normale
nn inserisce nulla,anke se il compilatore non da errore...
Ringrazio in anticipo coloro i quali risponderanno.
Dunque quando in c bisogna sempre usare il
doppio puntatore e perchè?
x esempio quando faccio l'inserimento in una lista o
in un albero perkè nn si può usare un puntatore normale?
faccio un esempio:
int insert(LISTA **head, SQUADRA buffer)
{
LISTA *paus,*punt;
if((paus=(LISTA *)malloc(sizeof(LISTA)))==NULL) return 0;
paus->etichetta=buffer;
if(*head==NULL){
paus->next=NULL;
*head=paus;
}
else{
punt=*head
while(punt->next!=NULL)
punt=punt->next;
paus->next=NULL;
punt->next=paus;
}
return 1;
questa procedura funziona bene se uso un puntatore normale
nn inserisce nulla,anke se il compilatore non da errore...
Ringrazio in anticipo coloro i quali risponderanno.