switch

This is a discussion on switch within the C++ Programming forums, part of the General Programming Boards category; how do i get back to the choice entry after the default??? printf("* Pls enter a choice : "); choice=getche(); ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    9

    Question switch

    how do i get back to the choice entry after the default???

    printf("* Pls enter a choice : ");
    choice=getche(); //<- HERE...
    switch(choice)
    {
    case '1': printf("\n\nBalance has been selected");
    resistor_colour();

    break;
    case '2': printf("Deposit has been selected\n");
    Sleep(2000);
    break;
    case '3': printf("Withdrawal has been selected\n");
    Sleep(2000);
    break;
    case '4':
    printf("Transfer has been selected\n");
    Sleep(2000);
    break;
    case '5': system("cls");
    printf("Thank you for using this service.\n");
    getch();
    exit(0);

    default: printf("\n\nERROR!!!");
    return();
    break;
    }

    }

  2. #2
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    359
    Code:
    printf("* Pls enter a choice : ");
    choice=getche(); //<- HERE...
      do
      {
        switch(choice)
        {
          case '1': printf("\n\nBalance has been selected");
          resistor_colour();
    
          break;
          case '2': printf("Deposit has been selected\n");
          Sleep(2000);
          break;
          case '3': printf("Withdrawal has been selected\n");
          Sleep(2000);
          break;
          case '4':
          printf("Transfer has been selected\n");
          Sleep(2000);
          break;
          case '5': system("cls");
          printf("Thank you for using this service.\n");
          getch();
          exit(0);
    
          default: printf("\n\nERROR!!!");
          return();
          break;
        }
      }while(/*Something*/)
    }
    Be a leader and not a follower.

  3. #3
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    359
    sorry.

    Code:
      do
      {
        printf("* Pls enter a choice : ");
        choice=getche(); //<- HERE...
    
        switch(choice)
        {
          case '1': printf("\n\nBalance has been selected");
          resistor_colour();
    
          break;
          case '2': printf("Deposit has been selected\n");
          Sleep(2000);
          break;
          case '3': printf("Withdrawal has been selected\n");
          Sleep(2000);
          break;
          case '4':
          printf("Transfer has been selected\n");
          Sleep(2000);
          break;
          case '5': system("cls");
          printf("Thank you for using this service.\n");
          getch();
          exit(0);
    
          default: printf("\n\nERROR!!!");
          return();
          break;
        }
      }while(/*Something*/)
    }
    Be a leader and not a follower.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. ascii rpg help
    By aaron11193 in forum C Programming
    Replies: 18
    Last Post: 10-29-2006, 01:45 AM
  3. Switch
    By cogeek in forum C Programming
    Replies: 4
    Last Post: 12-23-2004, 06:40 PM
  4. Switch Case
    By FromHolland in forum C++ Programming
    Replies: 7
    Last Post: 06-13-2003, 04:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21