Cosa sbaglio??
compila mi da un risultato esatto però mi scompare subito tutto!codice:typedef struct node { int value; struct node* next; } node; typedef node* link; void stampaLista(link pLista); node* add_element_h(link head, int new_val); int main(int argc, char *argv[]) { link mialista; mialista=add_element_h(mialista, 5); mialista=add_element_h(mialista, 56); mialista=add_element_h(mialista, 53); stampaLista(mialista); system("PAUSE"); return 0; } void stampaLista(link pLista) { printf("\n"); while (pLista!=NULL) { printf("value: %d\n", pLista->value); pLista = pLista->next; } } node* add_element_h(link head, int new_val) { node* new_elem = (node *)malloc(sizeof(node)); if(new_elem==NULL){ printf("errore nell'allocazione di new_elem\n"); return NULL; } new_elem->value = new_val; new_elem->next = head;//head of list return new_elem; }

Rispondi quotando