RISOLTO iscrizione e login

Stato
Discussione chiusa ad ulteriori risposte.

sare1234

Utente Attivo
262
3
Buongiorno ho un problema nel mio progetto devo differenziare tra utente Admin ed utente normale per quanto riguarda l'accesso ho utilizzato una lista in pratica devo fare in modo che se entro come Admin e poi mi iscrivo come utente ed accedo devo poter accedere con le credenziali dell'utente
List.c
Codice:
#include <stdlib.h>
#include "ListUtente.h"
#include <string.h>
#include <stdio.h>
ListUtente initListUtente(char name[50], char surname[50], char email[100],char password[7], bool isAdmin)
{
    ListUtente L = (ListUtente)malloc(sizeof(struct Utente));
    strcpy(L->name, name);
    strcpy(L->surname, surname);
    strcpy(L->email, email);
    strcpy(L->password, password);
    L->isAdmin =isAdmin;
    L->next = NULL;
    return L;
}


void user_exist(ListUtente L, char name[50], char surname[50], char email[100], char password[7], bool isAdmin) {
    struct Utente *tmp;
    tmp = L->next;
    if (tmp != NULL)
     {
         if (strcmp(tmp->name,name)==0 && strcmp(tmp->surname,surname)==0 && strcmp(tmp->email,email)==0 && strcmp(tmp->password, password)==0 && tmp->isAdmin==isAdmin)
            {
                printf("\n Benvenuto %s %s \n", tmp->name, tmp->surname);
            }
         user_exist(tmp->next,name,surname,email,password,isAdmin);
      }

}


ListUtente user_push(ListUtente L, char name[50], char surname[50], char email[100], char password[7], bool isAdmin)
{
    if (L != NULL){
        L->next = user_push(L->next,name,surname,email,password,isAdmin);
            } else{
                L = initListUtente(name,surname,email, password,isAdmin);
            }
    return L;
}
list.h
C:
#ifndef ListUtente_h
#define ListUtente_h
#include <stdbool.h>


#include <stdio.h>
struct Utente{
    char name[50];
    char surname[50];
    char email[100];
    char password[7];
    bool isAdmin;
    struct Utente* next;
};

typedef struct Utente* ListUtente;

ListUtente initListUtente(char name[50], char surname[50], char email[100],char password[7], bool isAdmin);
void user_exist(ListUtente L, char name[50], char surname[50], char email[100], char password[7], bool isAdmin);
ListUtente user_push(ListUtente L,char name[50], char surname[50], char email[100], char password[7], bool isAdmin);
#endif /* ListUtente_h */

main.c
C:
                    /*progetto gestione delle prenotazioni di voli.*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <assert.h>
#include <string.h>
#include <stdbool.h>
#include "Graph.h"
#include "List.h"
#include "Queue.h"
#include "Menu.h"
#include "ListPrenotazioni.h"
#include "ListUtente.h"

#define BUFFER_SIZE 256
#define  randomize srand(((unsigned int) time(NULL)))
#define  random(x) rand()%x

int main(int argc, char** argv){
 bool Admin;
 char name[50];
 char surname[50];
 char cityDestination[10];
 char deleteCity[10];
 char city[10];
 char cityPartenza[10];
 char cod_id[7];
 int n=1,m=1;
 char email[100];
 char pwd[7];
 ListPrenotazioni L = NULL;//per listPrenotazioni
 ListUtente l = NULL;//per listUtente
 randomize;
 Graph g = populateGraph();
 char mostPopularDestination = random(g->nodes_count);
 char buffer_email[BUFFER_SIZE];
 char buffer_password[BUFFER_SIZE];
 int loginChoice;
 int adminChoice;
 int userChoice;
 int user1Choice;
 int user2Choice;
 bool continueLoop;
 double price;
 double distance;
    int p;

do{
    loginChoice = LoginMenu();
    if(loginChoice == 0){  /*azioni amministratore*/
        continueLoop = true;
          
              Admin=true;
        
           printf("Insert name: ");
           scanf("%s", name);
        
           printf("Insert surname: ");
           scanf("%s", surname);

            printf("Insert e-mail: ");
            scanf("%s", buffer_email);
                    
            printf("Insert password (max 7 characters): ");
            scanf("%s", buffer_password);
            
               l = user_push(l,name,surname,email,pwd,Admin);
               user_exist(l,name,surname,email,pwd,Admin);

            /*
            Se l'admin non e' presente nella data structure degli admin --> continueLoop = false
                In questo modo torna al menu di login e non vengono eseguite operazioni
            */
            while(continueLoop){
                
             adminChoice = AdminMenu();
                
              switch (adminChoice){
                      
               case 0: // exit / logout
                                            
                    continueLoop = false;
                      
                    break;
               case 1: /* stampa destinazioni e tratte*/
                      
                printf("\nThe destinations are as follows:\n");
                      
                    PrintGraph(g);
                      
                    break;
               case 2: /*inserisci destinazioni e tratte*/
                

          addNode(g, getCityName("new destination(first uppercase character)"));
                      
                printf("\nInserire numero tratte da inserire:\n");
                scanf("%d",&p);
                for(int v=0; v<p; v++){
                      
                printf("\nInsert price(es. 23.78):%d ",v);
                 scanf("%lf", &price);
                    
                 printf("\nInsert distance(es. 345.98):%d",v);
                 scanf("%lf", &distance);
                
                    
           addEdge(g,getCityIndexByName(g,getCityName("new destination(first uppercase character)")), getCityIndexByName(g, getCityName("new destination(first uppercase character)")),price,distance);
                    
                      }
                  
                      printf("\n~Operation successfully performed~\n");
                      
                    break;
                case 3: /*cancella destinazioni e tratte*/
                      
                     printf("Insert the city to be deleted:\n");
                     scanf("%s", deleteCity);
                                              
                     removeNodeByString(g,deleteCity);

                     printf("~\nOperation successfully performed~\n");
                
                    break;
                    
                    default: /*Se l'utente sbaglia ad inserire il numero*/
                        printf("This button does not allow you to make choices! Try again!\n");

                           break;
                    
                }
            }
         }else if(loginChoice == 1){ /*azioni utenti*/
             continueLoop = true;
              Admin=false;
               while(continueLoop){
                user1Choice = UserMenu1();
                  switch (user1Choice){
                          
                      case 0: // exit / logout
                          
                            continueLoop = false;
                          
                            break;
                          
                   case 1: /*effettuo iscrizione*/
                            
                        for(int i=0; i<n; i++){
                            
                            printf("\nInsert name:\n");
                            scanf("%s", name);
                            printf("\nInsert surname:\n");
                            scanf("%s", surname);
                            printf("\nInsert e-mail:\n");
                            scanf("%s",email);
                            printf("\nInsert password:\n");
                            scanf("%s",pwd);
                                                        
                            }
                          l=user_push(l,name,surname,email,pwd,Admin);

                                break;
                              
                    case 2: /*effettuo accesso*/
                          
                                printf("\nInsert e-mail:\n");
                                scanf("%s",email);
                                printf("\nInsert surname:\n");
                                scanf("%s",surname);
                                printf("\nInsert password:\n");
                                scanf("%s",pwd);
                          user_exist(l,name,surname,email,pwd,Admin);
                          
                    // printf("~\nLogin successful~\n");

                    if(loginChoice == 1){ /*azioni utenti*/
                        continueLoop = true;
                    while (continueLoop){
                    userChoice = UserMenu();
                        switch (userChoice){
                                
                            case 0:
                                
                                continueLoop = false;
                                
                                break;
                      case 1:  /*vedi prenotazioni attive*/
                                                              
                         printf("\nThe destinations are as follows:\n");
                                            
                            PrintGraph(g);
                        
                                break;
                                
                        
                           case 2: /*effettua prenotazione*/
                                
                            if(loginChoice == 1){ /*azioni utenti*/
                             continueLoop = true;
                               while (continueLoop){
                                user2Choice = UserMenu2();
                                  switch (user2Choice){
                                          
                                case 0:
                                          
                                 continueLoop = false;
                                          
                                    break;
                                          
                                case 1: /*Prenotazione basata sul meno scambi inserendo la città di partenza e la città di destinazione*/
                                          
                                          printf("\nInserisci città di partenza: ");
                                          scanf("%s", cityPartenza);
                                          
                                          printf("\nInserisci città di destinazione: ");
                                          scanf("%s", cityDestination);

                                          //inserire funzione per determinare tratta più economica
                                          
                                    printf("Enter the number of reservations you wish to make\n");
                                         scanf("%d",&m);
                                          
                                         for (int i=0; i<m; i++){
                                            
                                         printf("\nInsert citta:\n");
                                         scanf("%s",city);
                                         printf("\nInsert id:\n");
                                         scanf("%s",cod_id);
                                            
                                         L = insertTailPrenotazioni(L,city,cod_id);
                                            
                                         }
                                             break;
                                          
                                case 2: /*Prenotazione basata sui percorsi più brevi inserendo la città di partenza e destinazione
                                    funzione per percorsi brevi*/
                                          
                                printf("\nInserisci città di partenza: ");
                                scanf("%s", cityPartenza);
                                                                                  
                                printf("\nInserisci città di destinazione: ");
                                scanf("%s", cityDestination);
                                          
                                //inserire funzione per determinare tratta più breve
                                          
                                printf("Enter the number of reservations you wish to make\n");
                                scanf("%d",&m);
                                          
                                         for (int i=0; i<m; i++){
                                            
                                         printf("\nInsert citta:\n");
                                         scanf("%s",city);
                                         printf("\nInsert id:\n");
                                         scanf("%s",cod_id);
                                            
                                         L = insertTailPrenotazioni(L,city,cod_id);
                                            
                                         }
                                
                                       break;
                                          
                                case 3: /*Prenotazione basata sulla destinazione più economica inserendo solo la città di partenza
                                    funzione per destinazione piu economica*/
                                          
                                     printf("\nInserisci città di partenza: ");
                                     scanf("%s", cityPartenza);
                                          
                                        //inserire funzione per la tratta più economica
                                    
                                    printf("Enter the number of reservations you wish to make\n");
                                         scanf("%d",&m);
                                          
                                         for (int i=0; i<m; i++){
                                            
                                         printf("\nInsert citta:\n");
                                         scanf("%s",city);
                                         printf("\nInsert id:\n");
                                         scanf("%s",cod_id);
                                            
                                         L = insertTailPrenotazioni(L,city,cod_id);
                                            
                                         }
                                            break;
                                          
                                case 4: /*Prenotazione basata sulla destinazione più popolare inserendo solo la città di partenza*/
                                          
                                    printf("\nEnter city of start: ");
                                    scanf("%s", cityPartenza);
                                    
                             printf("\n The most popular destination is the following:\n");
                                          
                                 mostPopularDestination = random(g->nodes_count);
                                    char* cityName = g->cityNames[mostPopularDestination];
                            
                                printf("id:%d city:%s\n",mostPopularDestination,cityName);

                                     printf("Enter the number of reservations you wish to make\n");
                                     scanf("%d",&m);
                                          
                                     for (int i=0; i<m; i++){
                                        
                                     printf("\nInsert citta partenza:\n");
                                     scanf("%s", city);
                                     printf("\nInsert id:\n");
                                     scanf("%s",cod_id);
                                        
                                     L = insertTailPrenotazioni(L,city,cod_id);
                                        
                                     }
                                  break;
                                          
                              case 5:  /*vedi prenotazioni attive*/
                                                            
                                printListPrenotazioni(L);
                                        break;
                                    }
                                  }
                                }
                    
            default: /*Se l'utente sbaglia ad inserire il numero*/
            printf("This button does not allow you to make choices! Try again!\n");
                                       break;
                                
                          }
                     }
                }
           }
       }
   }
    
    }while(loginChoice != 2);
        printf("Thanks for choosing us, come back to visit us!\n");
            return 0;
}

Ma mi da questo errore
1591942588361.png

In pratica e come se nella listaUtenti L non ci sia nulla....Sapete come posso risolvere??
Grazie in anticipo
 

theprogrammer.99

Nuovo Utente
96
34
In queste due chiamate

Codice:
l = user_push(l,name,surname,email,pwd,Admin);
user_exist(l,name,surname,email,pwd,Admin);

usi

email
pwd

ma nelle scanf precedenti

Codice:
           printf("Insert e-mail: ");
            scanf("%s", buffer_email);
                    
            printf("Insert password (max 7 characters): ");
            scanf("%s", buffer_password);

utilizzi

buffer_email
buffer_password

Che senso ha?

P.S. La schermata che hai mostrato fa riferimento ad un altro codice perché usi altre variabili ... se non mostri il codice che usi, non si capirà mai nulla
 
Ultima modifica:

sare1234

Utente Attivo
262
3
In queste due chiamate

Codice:
l = user_push(l,name,surname,email,pwd,Admin);
user_exist(l,name,surname,email,pwd,Admin);

usi

email
pwd

ma nelle scanf precedenti

Codice:
           printf("Insert e-mail: ");
            scanf("%s", buffer_email);
                   
            printf("Insert password (max 7 characters): ");
            scanf("%s", buffer_password);

utilizzi

buffer_email
buffer_password

Che senso ha?

P.S. La schermata che hai mostrato fa riferimento ad un altro codice perché usi altre variabili ... se non mostri il codice che usi, non si capirà mai nulla
il problema è che ho prova ad inserire buffer email e password ma non mi funziona..quello è il codice che ho usato non ci sono altri codici
 

theprogrammer.99

Nuovo Utente
96
34
Ma comprendi quello che ti ho scritto? Quel codice è SBAGLIATO se utilizzi variabili diverse ... Inserisci il codice corretto poi dici esattamente che vuol dire "non funziona".
 
Ultima modifica:

sare1234

Utente Attivo
262
3
Ma comprendi quello che ti ho scritto? Quel codice è SBAGLIATO se utilizzi variabili diverse ... Inserisci il codice corretto poi dici esattamente che vuol dire "non funziona".
Codice:
                    /*progetto gestione delle prenotazioni di voli.*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <assert.h>
#include <string.h>
#include <stdbool.h>
#include "Graph.h"
#include "List.h"
#include "Queue.h"
#include "Menu.h"
#include "ListPrenotazioni.h"
#include "ListUtente.h"

#define BUFFER_SIZE 256
#define  randomize srand(((unsigned int) time(NULL)))
#define  random(x) rand()%x

int main(int argc, char** argv){
bool Admin;
char name[50];
char surname[50];
char cityDestination[10];
char deleteCity[10];
char city[10];
char cityPartenza[10];
char cod_id[7];
int n=1,m=1;
char email[100];
char pwd[7];
ListPrenotazioni L = NULL;//per listPrenotazioni
ListUtente l = NULL;//per listUtente
randomize;
Graph g = populateGraph();
char mostPopularDestination = random(g->nodes_count);
//char buffer_email[BUFFER_SIZE];
//char buffer_password[BUFFER_SIZE];
int loginChoice;
int adminChoice;
int userChoice;
int user1Choice;
int user2Choice;
bool continueLoop;
double price;
double distance;
    int p;

do{
    loginChoice = LoginMenu();
    if(loginChoice == 0){  /*azioni amministratore*/
        continueLoop = true;
         
              Admin=true;
       
           printf("Insert name: ");
           scanf("%s", name);
       
           printf("Insert surname: ");
           scanf("%s", surname);

            printf("Insert e-mail: ");
            scanf("%s", email);
                   
            printf("Insert password (max 7 characters): ");
            scanf("%s", pwd);
           
               l = user_push(l,name,surname,email,pwd,Admin);
               user_exist(l,name,surname,email,pwd,Admin);

            /*
            Se l'admin non e' presente nella data structure degli admin --> continueLoop = false
                In questo modo torna al menu di login e non vengono eseguite operazioni
            */
            while(continueLoop){
               
             adminChoice = AdminMenu();
               
              switch (adminChoice){
                     
               case 0: // exit / logout
                                           
                    continueLoop = false;
                     
                    break;
               case 1: /* stampa destinazioni e tratte*/
                     
                printf("\nThe destinations are as follows:\n");
                     
                    PrintGraph(g);
                     
                    break;
               case 2: /*inserisci destinazioni e tratte*/
               

          addNode(g, getCityName("new destination(first uppercase character)"));
                     
                printf("\nInsert number of sections to be entered:\n");
                scanf("%d",&p);
                for(int v=0; v<p; v++){
                     
                printf("\nInsert price(es. 23.78):%d ",v);
                 scanf("%lf", &price);
                   
                 printf("\nInsert distance(es. 345.98):%d",v);
                 scanf("%lf", &distance);
               
                   
           addEdge(g,getCityIndexByName(g,getCityName("new destination(first uppercase character)")), getCityIndexByName(g, getCityName("new destination(first uppercase character)")),price,distance);
                   
                      }
                 
                      printf("\n~Operation successfully performed~\n");
                     
                    break;
                case 3: /*cancella destinazioni e tratte*/
                     
                     printf("Insert the city to be deleted:\n");
                     scanf("%s", deleteCity);
                                             
                     removeNodeByString(g,deleteCity);

                     printf("~\nOperation successfully performed~\n");
               
                    break;
                   
                    default: /*Se l'utente sbaglia ad inserire il numero*/
                        printf("This button does not allow you to make choices! Try again!\n");

                           break;
                   
                }
            }
         }else if(loginChoice == 1){ /*azioni utenti*/
             continueLoop = true;
              Admin=false;
               while(continueLoop){
                user1Choice = UserMenu1();
                  switch (user1Choice){
                         
                      case 0: // exit / logout
                         
                            continueLoop = false;
                         
                            break;
                         
                   case 1: /*effettuo iscrizione*/
                           
                        for(int i=0; i<n; i++){
                           
                            printf("\nInsert name:\n");
                            scanf("%s", name);
                            printf("\nInsert surname:\n");
                            scanf("%s", surname);
                            printf("\nInsert e-mail:\n");
                            scanf("%s",email);
                            printf("\nInsert password:\n");
                            scanf("%s",pwd);
                                                       
                            }
                          l=user_push(l,name,surname,email,pwd,Admin);

                                break;
                             
                    case 2: /*effettuo accesso*/
                         
                                printf("\nInsert e-mail:\n");
                                scanf("%s",email);
                                printf("\nInsert password:\n");
                                scanf("%s",pwd);
                          user_exist(l,name,surname,email,pwd,Admin);
                       
                          printf("\n welcome %s %s \n", name, surname);


                         
                    // printf("~\nLogin successful~\n");

                    if(loginChoice == 1){ /*azioni utenti*/
                        continueLoop = true;
                    while (continueLoop){
                    userChoice = UserMenu();
                        switch (userChoice){
                               
                            case 0:
                               
                                continueLoop = false;
                               
                                break;
                      case 1:  /*vedi prenotazioni attive*/
                                                             
                         printf("\nThe destinations are as follows:\n");
                                           
                            PrintGraph(g);
                       
                                break;
                               
                       
                           case 2: /*effettua prenotazione*/
                               
                            if(loginChoice == 1){ /*azioni utenti*/
                             continueLoop = true;
                               while (continueLoop){
                                user2Choice = UserMenu2();
                                  switch (user2Choice){
                                         
                                case 0:
                                         
                                 continueLoop = false;
                                         
                                    break;
                                         
                                case 1: /*Prenotazione basata sul meno scambi inserendo la città di partenza e la città di destinazione*/
                                         
                                          printf("\nInserisci città di partenza: ");
                                          scanf("%s", cityPartenza);
                                         
                                          printf("\nInserisci città di destinazione: ");
                                          scanf("%s", cityDestination);

                                          //inserire funzione per determinare tratta più economica
                                         
                                    printf("Enter the number of reservations you wish to make\n");
                                         scanf("%d",&m);
                                         
                                         for (int i=0; i<m; i++){
                                           
                                         printf("\nInsert citta:\n");
                                         scanf("%s",city);
                                         printf("\nInsert id:\n");
                                         scanf("%s",cod_id);
                                           
                                         L = insertTailPrenotazioni(L,city,cod_id);
                                           
                                         }
                                             break;
                                         
                                case 2: /*Prenotazione basata sui percorsi più brevi inserendo la città di partenza e destinazione
                                    funzione per percorsi brevi*/
                                         
                                printf("\nInserisci città di partenza: ");
                                scanf("%s", cityPartenza);
                                                                                 
                                printf("\nInserisci città di destinazione: ");
                                scanf("%s", cityDestination);
                                         
                                //inserire funzione per determinare tratta più breve
                                         
                                printf("Enter the number of reservations you wish to make\n");
                                scanf("%d",&m);
                                         
                                         for (int i=0; i<m; i++){
                                           
                                         printf("\nInsert citta:\n");
                                         scanf("%s",city);
                                         printf("\nInsert id:\n");
                                         scanf("%s",cod_id);
                                           
                                         L = insertTailPrenotazioni(L,city,cod_id);
                                           
                                         }
                               
                                       break;
                                         
                                case 3: /*Prenotazione basata sulla destinazione più economica inserendo solo la città di partenza
                                    funzione per destinazione piu economica*/
                                         
                                     printf("\nInserisci città di partenza: ");
                                     scanf("%s", cityPartenza);
                                         
                                        //inserire funzione per la tratta più economica
                                   
                                    printf("Enter the number of reservations you wish to make\n");
                                         scanf("%d",&m);
                                         
                                         for (int i=0; i<m; i++){
                                           
                                         printf("\nInsert citta:\n");
                                         scanf("%s",city);
                                         printf("\nInsert id:\n");
                                         scanf("%s",cod_id);
                                           
                                         L = insertTailPrenotazioni(L,city,cod_id);
                                           
                                         }
                                            break;
                                         
                                case 4: /*Prenotazione basata sulla destinazione più popolare inserendo solo la città di partenza*/
                                         
                                    printf("\nEnter city of start: ");
                                    scanf("%s", cityPartenza);
                                   
                             printf("\n The most popular destination is the following:\n");
                                         
                                 mostPopularDestination = random(g->nodes_count);
                                    char* cityName = g->cityNames[mostPopularDestination];
                           
                                printf("id:%d city:%s\n",mostPopularDestination,cityName);

                                     printf("Enter the number of reservations you wish to make\n");
                                     scanf("%d",&m);
                                         
                                     for (int i=0; i<m; i++){
                                       
                                     printf("\nInsert citta partenza:\n");
                                     scanf("%s", city);
                                     printf("\nInsert id:\n");
                                     scanf("%s",cod_id);
                                       
                                     L = insertTailPrenotazioni(L,city,cod_id);
                                       
                                     }
                                  break;
                                         
                              case 5:  /*vedi prenotazioni attive*/
                                                           
                                printListPrenotazioni(L);
                                        break;
                                    }
                                  }
                                }
                   
            default: /*Se l'utente sbaglia ad inserire il numero*/
            printf("This button does not allow you to make choices! Try again!\n");
                                       break;
                               
                          }
                     }
                }
           }
       }
   }
   
    }while(loginChoice != 2);
        printf("Thanks for choosing us, come back to visit us!\n");
            return 0;
}
mi da lo stesso l'errore nella foto precedente se inserisco prima l'amministratore e poi faccio l'iscrizione per l'utente ed accedo
ListUtente.c
Codice:
#include <stdlib.h>
#include "ListUtente.h"
#include <string.h>
#include <stdio.h>
ListUtente initListUtente(char name[50], char surname[50], char email[100],char password[7], bool isAdmin)
{
    ListUtente L = (ListUtente)malloc(sizeof(struct Utente));
    strcpy(L->name, name);
    strcpy(L->surname, surname);
    strcpy(L->email, email);
    strcpy(L->password, password);
    L->isAdmin =isAdmin;
    L->next = NULL;
    return L;
}


void user_exist(ListUtente L, char name[50], char surname[50], char email[100], char password[7], bool isAdmin) {
    struct Utente *tmp;
    tmp = L->next;
    if (tmp != NULL)
     {
         if (strcmp(tmp->name,name)==0 && strcmp(tmp->surname,surname)==0 && strcmp(tmp->email,email)==0 && strcmp(tmp->password, password)==0 && tmp->isAdmin==isAdmin)
            {
                printf("\n Benvenuto %s %s \n", tmp->name, tmp->surname);
            }
         user_exist(tmp->next,name,surname,email,password,isAdmin);
      }

}


ListUtente user_push(ListUtente L, char name[50], char surname[50], char email[100], char password[7], bool isAdmin)
{
    if (L != NULL){
        L->next = user_push(L->next,name,surname,email,password,isAdmin);
            } else{
                L = initListUtente(name,surname,email, password,isAdmin);
            }
    return L;
}
questo e il codice a cui fa riferimento
 

sare1234

Utente Attivo
262
3
1591947599935.png
Menu.c
Codice:
#include <stdio.h>
#include "Menu.h"

int LoginMenu(){
    int choice = -1;
    printf(" * * * * * * * * * * * * * * * * * * * * * * * *   Welcome to flight booking management\n * * * * * * * * * * * * * * * * * * * * * * * *  \n");
    printf("Who are you?\n");
    printf(" 0. Admin\n");
    printf(" 1. User\n");
    printf(" 2. Exit\n");
    printf("Insert your choice:");
    scanf("%d",&choice);
    while (choice < 0 || choice > 2) {
      printf("This button does not allow you to make choices! Try again!\n");
      printf("Insert choice thanks: ");
      scanf("%d", &choice);
        return choice;
    }
    return choice;
}

int AdminMenu(){
    int choice = -1;

    printf("                   **************** \n");
    printf("                     ADMINISTATOR        \n");
    printf("                   ****************     \n");

    printf(" 0. Logout\n");
    printf(" 1. Print destinations\n");
    printf(" 2. Insert destinations\n");
    printf(" 3. Delete destinations\n");
    
    printf("Insert your choice:");
    scanf("%d",&choice);
    while (choice < 0 || choice > 3) {
    printf("This button does not allow you to make choices! Try again!\n");
       printf("Insert your choice:");
       scanf("%d", &choice);
      return choice;

    
    }
    return choice;
}

int UserMenu(){
    int choice = -1;
    printf("  \n                   **************** \n");
    printf("                         USER          \n");
    printf("                   ****************     \n");
    
    printf(" 0. LogOut\n");
    printf(" 1. List of available cities\n");
    printf(" 2. Make reservation\n");
    printf("Insert your choice:");
    scanf("%d",&choice);
    while (choice < 0 || choice > 3) {
       printf("This button does not allow you to make choices! Try again!\n");
       printf("Insert your choice:");
       scanf("%d", &choice);
         return choice;
    }
    return choice;
}


int UserMenu1(){
    int choice = -1;

    printf("                   **************** \n");
    printf("                         USER          \n");
    printf("                   ****************     \n");
    
    printf(" 0. LogOut\n");
    printf(" 1. SignUp\n");
    printf(" 2. SignIn\n");
    
    printf("Insert your choice:");
    scanf("%d",&choice);
       while (choice < 0 || choice > 2) {
          printf("This button does not allow you to make choices! Try again!\n");
          printf("Insert your choice:");
          scanf("%d", &choice);
            return choice;
       }
        
    return choice;
}

int UserMenu2(){
    int choice = -1;

    printf("                   **************** \n");
    printf("                         USER          \n");
    printf("                   ****************     \n");
    
    printf(" 0. LogOut\n");
    printf(" 1. Booking based on the shortest route by entering the city and the departure destination\n");
    printf(" 2. Booking based on the shortest routes by entering the city of departure and destination\n");
    printf(" 3. Booking based on the cheapest destination by entering only the city of departure\n");
    printf(" 4. Booking based on the most popular destination by entering only the city of departure\n");
    printf(" 5. View prenotations\n");
    printf("Insert your choice:");
    scanf("%d",&choice);
       while (choice < 0 || choice > 5) {
          printf("This button does not allow you to make choices! Try again!\n");
          printf("Insert your choice:");
          scanf("%d", &choice);
            return choice;
       }
        
    return choice;
}
Post unito automaticamente:

Il tuo codice è altamente confuso. Quale menu utilizzi? Intendo nel codice .... perché tutte le funzioni Menu non le hai postate ...
le ho inserito
 

sare1234

Utente Attivo
262
3
non ho capito cosa?
secondo me il problema che ho in foto dipende da questa funzione
C:
void user_exist(ListUtente L, char name[50], char surname[50], char email[100], char password[7], bool isAdmin) {
    struct Utente *tmp;
    tmp = L->next;
    if (tmp != NULL)
     {
         if (strcmp(tmp->name,name)==0 && strcmp(tmp->surname,surname)==0 && strcmp(tmp->email,email)==0 && strcmp(tmp->password, password)==0 && tmp->isAdmin==isAdmin)
            {
                printf("\n Benvenuto %s %s \n", tmp->name, tmp->surname);
            }
         user_exist(tmp->next,name,surname,email,password,isAdmin);
      }

}
Quando faccio questo:
struct Utente *tmp;
Post unito automaticamente:

Io avvio il programma .... e poi cosa devo scrivere in sequenza esattamente per arrivare all'errore??
entrare come amministratore, poi iscriversi come utente ed accedere come autente con le credenziali messe nell'iscrizione
 
Stato
Discussione chiusa ad ulteriori risposte.

Ci sono discussioni simili a riguardo, dai un'occhiata!

Entra

oppure Accedi utilizzando
Discord Ufficiale Entra ora!

Discussioni Simili