Thread: Menu And Sub Menu

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    3

    Menu And Sub Menu

    Hi All I am starting Make a programa I got Already Maked something really Hard that Is Screen Cleanr Coz for dont work system("cls"); i am Xp User XD! and So I was reading and looking and found a good method for do SCREEN CLEAR ! I do public this code

    here i make an Attachme of the Header Code ! for use in any programa Just Need tell
    #include "cleaner.h" //*is in " " Only that is the file Are in the same Folder But if you wanna pacht it this form!//**
    #include <cleaner.h>
    clrscr();
    Tell me if i wrong >.<!

    But Now I wanna Do a Menu And Sub Menu for a Program

    Justi Like This

    >Panel Administrative
    >>1.- Opcion 1
    >>2.- Opcion 2
    >>3.- Opcion 3
    >>4.- Opcion 4
    >Opcion 1
    >>1.Option 1.1
    >>2.Option 1.2
    >>3.Option 1.3
    >>4.Option 1.4
    >Opcion 2
    >>1.Option 1.1
    >>2.Option 1.2
    >>3.Option 1.3
    >>4.Option 1.4
    >Opcion 3
    >>1.Option 1.1
    >>2.Option 1.2
    >>3.Option 1.3
    >>4.Option 1.4
    >Opcion 4
    >>1.Option 1.1
    >>2.Option 1.2
    >>3.Option 1.3
    >>4.Option 1.4


    So how i can do it >.<!!!! i will very gratefull with it >.<!!!

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    *blinks*
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    3
    can you tell me a simple example please !

  4. #4
    Registered User
    Join Date
    Jun 2009
    Posts
    486
    Use a nested switch - get the user input, switch it for options 1 through 4, and for each of those, get another input and switch that one for options .1 through .4. The rest is just printing and calling whatever functions the input asks for.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    You'd have a mainMenu function, and one subMenu function for each option.

    so:
    Code:
    int main() {
      mainMenu() //call mainMenu
      return 0
    }
    mainMenu() {
      begin your loop: 
        show choices & get user's input
        call the function needed for the user's choice
        control returns here, and
      loops while input != 9 (whatever quit value you want)
      
    }
    option1() {
      handle the work that the user requested 
      and return to the mainMenu()
    
      if you have another layer of menu's to deal with, then
      make another loop like mainMenu() uses, and call the 
      right function, from the user's choice in this menu.
    
    }
    If you'll post up some code, and ask specific questions about that code, we can be more helpful about what has you stumped.

  6. #6
    Registered User
    Join Date
    Jul 2010
    Posts
    3
    Si but I maked Somethin Like This

    int main (int argc, char** argv)
    {
    int opciones;
    int exit = 0;
    FILE * fp;

    {
    menup();
    printf("\nOpciones: ");
    scanf("%d",&opciones);
    switch(opciones)
    {
    case 1:
    instalarD(fp);
    break;
    case 2:
    incluir(fp);
    break;
    case 3:
    verC(fp);
    break;
    case 4:
    exit = 1;
    break;
    default:
    printf("Porfavor Introduzca una opcion valida");
    }
    }
    When I make

    Void InstalarD(FILE *fp)
    {
    HERE SUB MENU HERE >.<! (another thing All the accion Going here no need right??)
    }

    how i do a submenu there >.<!!!

Popular pages Recent additions subscribe to a feed