0

can you help me in this MENU in C ? I want to return to the principal menu with goto bet it doesn't work.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <windows.h>
int main ()
{
    int a;
    start:




    printf("__________________________________________\n");
    printf("______________MENU________________________\n");
// principal menu
    printf("VEUILLEZ CHOISIR UNE DES FONCTIONNALITES SUIVANTES :\n 1-GESTION DES LISTES DES FAVORIS \n 2-APPLICATION SUR LES RPOFILS \n 3-APPLICATION SUR OPERATEURS \n -->  ");
   scanf("%d",&a);
   while ( a>3 )
   {
        printf("MAUVAIS CHOIX !! RESSAISISEZ LE NUMERO \n -->");// if we introduce a false number
        scanf("%d",&a);

   }

   switch (a) {
      case 1 :
           {
               int z;
               system("cls");
               printf("1- LISTER LA LISTE DES FAVORIS \n 2-AJOUTER UN NUMERO A LA LISTE DES FAVORIS \n 3-MODIFIER UN NUMERO \n 3- SUPPRIMER UN NUMERO FAVORIS \n 4- back \n -->");// submenu
              scanf("%d ",&z);
               while (z>4)
               {
                   printf("MAUVAIS CHOIX !! RESSAISISEZ LE NUMERO \n -->");
                   scanf("%d \n",&z);
               }

               switch (z) {// submenue
                  case 1 : system("cls"); break;
                  case 2 :system("cls");break ;
                  case 3 :system("cls"); break ;
                  case 4 : goto start; break;

                  default : printf("y a que 3 choix");
           }
      case  2 : system("cls");
      break;
       case 3 :system("cls"); break;
           }
   }

   return 0;
}

so when I press "back" it returns nothing.and when I press another time on "4" it returns but it print "MAUVAIS CHOIX!RESSAISISSEZ LE NUMERO".

Kiko
  • 13
  • 3
  • `scanf("%d \n",&z);` --> `scanf("%d",&z);` Otherwise, you'd need an extra newline to satisfy the conversion specifier. – Sourav Ghosh May 18 '21 at 10:34
  • It's worse than that, @SouravGhosh. You must type a non-whitespace character after the number — which will become the first character of the next input, which requires prescience on the part of the user. – Jonathan Leffler May 18 '21 at 10:45

0 Answers0