Thread: fgets in switch-case problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    4

    fgets in switch-case problem

    Hi,

    I have a problem with fgets inside a case where it doesn't even allow me to enter input, it just suddenly goes into the function after or back to the 'choose' menu, can someone tell me why it's like this and how to fix it? Doesn't seem to have any problems outside fo a switch-case statement.

    Code:
    #define MAX_INPUT 5
    char string[5];
    switch (choose())
    {
    	case 1:
    		printf("Enter no more than 5 characters:  \n");
    		fgets(string, MAX_INPUT, stdin);  
    		useInput(string);
    		break;
     	case 2:
    		funct2();
    		break;
    	case 3:
    		funct3();
    		break;
    
    }
    Last edited by icestorm; 08-20-2009 at 04:05 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 03-05-2009, 11:32 AM
  2. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  3. Base converter libary
    By cdonlan in forum C++ Programming
    Replies: 22
    Last Post: 05-15-2005, 01:11 AM
  4. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 10:18 PM
  5. Extra printed stmts...why?
    By mangoz in forum C Programming
    Replies: 4
    Last Post: 12-19-2001, 07:56 AM