Salve a tutti, ho aperto questo topic a causa di un errore che ho scovato in fase di compilazione di un mio progetto in linguaggio C che ha il semplice compito di creare una lista di interi senza segno avente i valori immessi dall ' utente e visualizzarla a video. Posto il codice cosicchè possiate scrutare il mio progetto in cerca
dell ' errore da me non capito :
Spero che leggendo questo codice da me scritto riusciretecodice:#include <stdio.h> #include <stdlib.h> #include <malloc.h> typedef struct Structure { unsigned int Value; struct Element * Next; }Element; Element * List; Element * Create_List ( ); void View_List ( Element * List ); int main ( ) { List = Create_List ( ); system ( "CLS" ); View_List ( List ); system ( "PAUSE" ); return 0; } Element * Create_List ( ) { Element * Pointer, * Scroller; unsigned int Elements; printf ( "How many items you want to create ? " ); scanf ( " %u ", & Elements ); if ( Elements == 0 ) Pointer = NULL; else if ( Elements > 0 ) { Pointer = ( Element * ) malloc ( sizeof (Element ) ); printf ( "Insert the value of the element : " ); scanf ( " %u ", & Pointer -> Value ); Scroller = Pointer; if ( Elements > 1 ) { for ( ; ( Elements - 1 ) >= 0 ; Elements-- ) { Scroller -> Next = ( Element * ) malloc ( sizeof (Element ) ); Scroller = Scroller -> Next; printf ( "Insert the value of the element : " ); scanf ( " %u ", & Pointer -> Value ); } } Scroller -> Next = NULL; } return Pointer; } void View_List ( Element * List ) { printf ( "List --->" ); while ( List != NULL ) { printf ( " %u --->", List -> Value ); } printf ( " NULL\n\n" ); }
a scovare gli errori che ahimè, io non sono riuscito a capire...
Ringrazio tutti per l'aiuto dato

Rispondi quotando