Thread: How to add the "QUIT APPLICTION" code in this???

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    8

    Unhappy How to add the "QUIT APPLICTION" code in this???

    GUYS which&where should i put the EXIT code in??Pls help..=(...Thx in advance...

    Code:
    #include<stdio.h>
    void menu();
    void submenu();
    main()
    {
    menu();
    return 0;
    }
    void menu()
    {
    char opt;
    do
    {
    printf ("*******************WELCOME TO MAS AIRLINE RESERVATION SYSTEM*******************\n");
    printf ("\nP ==> Ticket Purchase\n");
    printf ("\nV ==> Viewing Seating Arrangement\n");
    printf ("\nQ ==> Quit the System\n");
    printf ("\nPlease Insert Your Choice : ");
    scanf ("%s",&opt);
    }while ((opt!='p') && (opt!='v') && (opt!='q'));
    if(opt=='p'||opt=='P')
    {
    	submenu();
    }
    }
    void submenu()
    {
    	char slct;
    do
    {
    printf ("\n**********TICKET PURCHASING MODULE**********");
    printf ("\nB ==> Business Class Ticket Purchase\n");
    printf ("\nE ==> Economy Class Ticket Purchase\n");
    printf ("\nM ==> Return to Main Menu\n");
    scanf ("%s",&slct);
    }while ((slct!='P'));
    }

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What do you mean? Your code quits currently if you enter 'q'...

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    8
    owh...sorry i didnt explain in more detail....=X...i meant i want the program to confirm the user action before quitting...???Like "R U SURE U WAN TO QUIT"???How am i suppose to do that??

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So, what have you tried so far?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Feb 2009
    Posts
    8
    i tried using this method but still to no avail...=(.....
    Code:
    exit(0);
    exit(EXIT_SUCCESS);
    exit(EXIT_FAILURE);

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by kahwei View Post
    i tried using this method but still to no avail...=(.....
    Code:
    exit(0);
    exit(EXIT_SUCCESS);
    exit(EXIT_FAILURE);
    All of those will exit your application immediately. If you need to ask a question, then you need to write code to do that.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Oct 2008
    Posts
    92
    I'm not sure but maybe this is what you looking for:

    Code:
    int done=1;
    {while(!done)
        // ....your code here
          printf(" 1- to quit, 0- to continue");
          scanf("%i", &done);
    }

  8. #8
    Registered User
    Join Date
    Feb 2009
    Posts
    8
    nynicue thx for ur code..=).....i change it a little and got it...TQ...=)....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  2. Add a dialog box to a tab
    By axr0284 in forum Windows Programming
    Replies: 0
    Last Post: 01-10-2005, 08:38 AM
  3. Access Database Editor
    By Grayson_Peddie in forum Tech Board
    Replies: 21
    Last Post: 01-06-2004, 07:20 AM
  4. easy visual c++ program problem,
    By DAIALOS in forum C++ Programming
    Replies: 2
    Last Post: 01-10-2003, 12:38 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM