Thread: Sorry just one more (case Multiple Selection)

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    6

    Sorry just one more (case Multiple Selection)

    This just wont print, i dont understand??
    anyone with suggestions?
    Code:
    {
    	int menu, i, customer;
    printf("\t\t\t *****************\n");
    printf("\t\t\t ****MAIN MENU****\n");
    printf("\t\t\t *****************\n\n");
    scanf("%d", &menu);
    switch (menu) {
    		case ' 1 ' :
    
    			printf(" - 1. To Enter Records\n");
    			
    		break;
    
    		case ' 2 ' : 
    			
    			printf(" - 2. To View Sorted Records\n");
    
      
    		break;
    
    		case ' 3 ' :
    			
    			printf(" - 3. To Update a record\n");
    
    		break;
    
    
    		case ' 4 ' :
    
    			printf(" - 4. To Delete a record\n");
    
    		break;
    
    		case ' 5 ' :
    			
    			printf(" - 5. To Search for a Record\n");
    		
    		default:
    			printf(" System shut down Goodbye!!\n");
    
    			
    			getche();
    			system("cls");
    			break;
    }


    Code tags added by kermi3

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    You are switching on an integer data type not a character type. Instead of..

    case ' 1 ':

    what you really want is

    case 1:

    if you were doing characters you wouldn't have spaces between the single quotes and the letter either... for example..

    case 'a':

    For the letter character a. Hope this helps.

  3. #3
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    In the future please use code tags.

    Info on code tages may be found here:
    http://www.cprogramming.com/cboard/s...threadid=13473
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Intel syntax on MinGW ?
    By TmX in forum Tech Board
    Replies: 2
    Last Post: 01-06-2007, 09:44 AM
  3. Base converter libary
    By cdonlan in forum C++ Programming
    Replies: 22
    Last Post: 05-15-2005, 01:11 AM
  4. Basic Data types continue
    By viryonia in forum C Programming
    Replies: 6
    Last Post: 03-10-2003, 10:21 AM
  5. rand()
    By serious in forum C Programming
    Replies: 8
    Last Post: 02-15-2002, 02:07 AM