Loop runs more than expected in C
So. Writing application in C, unix, and i have function, which requests user input until input is valid.
lets go straight:

    int inputX()
    {
        int result;
    	char input;
    	while(1)
    	{
    		printf("Input x (a, b, c, d, e, f, g, h) :");
    		scanf("%c", &input);
    		result = validChar(input);
    		if (result >= 0)
    		{
    			return result;	
    		}
    		else
    		{
    			printf("Invlid input. Lets try again.\n");
    		}
     	}
    }

validChar() checks if input is a - h.
If i input a - everything is fine.
If i input e.g. 1, output is

    Input x (a, b, c, d, e, f, g, h) :1
    Invlid input. Lets try again.
    Input x (a, b, c, d, e, f, g, h) :Invlid input. Lets try again.
    Input x (a, b, c, d, e, f, g, h) :

i even tried sleep(), but didnt work..
C is tricky : |
Loop runs more than expected in C
===

So. Writing application in C, unix, and i have function, which requests user input until input is valid.
lets go straight:

    int inputX()
    {
        int result;
    	char input;
    	while(1)
    	{
    		printf("Input x (a, b, c, d, e, f, g, h) :");
    		scanf("%c", &input);
    		result = validChar(input);
    		if (result >= 0)
    		{
    			return result;	
    		}
    		else
    		{
    			printf("Invlid input. Lets try again.\n");
    		}
     	}
    }

validChar() checks if input is a - h.
If i input a - everything is fine.
If i input e.g. 1, output is

    Input x (a, b, c, d, e, f, g, h) :1
    Invlid input. Lets try again.
    Input x (a, b, c, d, e, f, g, h) :Invlid input. Lets try again.
    Input x (a, b, c, d, e, f, g, h) :

i even tried sleep(), but didnt work..
C is tricky : |