Hello everyone i am new to this forum. I am italian but I had to come to english forums becouse you can find more people to share your knowledge (and problems....) with.
I am working on a command line program that helps you to manage a list of invited people to an event and check their confirmation and their +1 (that's how in itlay we say when you bring someone with you wich is not in the list, I gues it is the same in english). Of course the programm will have to save the data onto a file not to lose them at every run. In order for a better controll on the list i decided to use a dynamic linked list instead of a vector (as it was in the first version i wrote).
Therefore i am now writing 4 functions that allows you to
0 (not created yet) check for existing data file and, in that case, import data from file
1 Receive the data from the imput to create a new list or just add a new invited
2 save the data on the file
3 print the data on the screen
I defined the struct of the "invited" wich is:
Ok now i have the function number 1 wich add a new invited to the list or, if the list doesn't exist, create the list and add a new invited. As the function 0 has not been created yet it jalways creates a new list. the code isCode:struct Invitato{ char nome[MAX]; // Means name char cognome[MAX]; // Means surmane int partecipa; // Confirmed partecipation = 1, not confirmed = 0, Maybe = 2 int uno; // The +1 i was talking about, same rules for partecipation struct Invitato *next; // pointer to next element }; typedef struct Invitato Invitato;
I'll just stop here for the moment, becouse that doesn't work and o can't get the reason.... Sorry for code being in italian, i promise i'll start writing in english the next times but i didn't have time to translate everithing. Any help?Code:Invitato *Inserisci_Invitato(Invitato *list){ Invitato *ptmp; ptmp = list; while (ptmp != NULL){ // Scorre la lista alla ricerca dell'ultima "cella", nel caso la lista sia vuota dovrebbe saltare l'operazione ptmp = ptmp->next; } ptmp=(Invitato *)malloc(sizeof(Invitato)); ptmp->next = NULL; printf("Inserisci Nome: "); scanf("%s", ptmp->nome); printf("Inserisci Cognome: "); scanf("%s", &ptmp->cognome); printf("Partecipazione confermata?(1=si, 0=no 2=forse) "); scanf("%d", &ptmp->partecipa); printf("+1? (1=si, 0=no, 2=forse) "); scanf("%d", &ptmp->uno); printf("\n"); return list; }



LinkBack URL
About LinkBacks


