I have the following code:
#include <stdio.h>
int opt;
scanf("%d",&opt);
while(opt!=0)
{
switch(opt)
{
case 1:func1();
break;
case 2:func2();
break;
case 3:return 0;
}
printf("\n");
scanf("%d",&opt);
}
I want to computer to get from user everytime different digit (1 or 2 or 3) and in every time the computer will run on seperate function. but when I press 2, func2 gets 3 ints and prints chars on the screen in a new line. the computer reads them instead of reading next input (1 or 2 or 3). how can I fix it?
EDIT: The problem rises only after specific inputs (I build a program converts bases).
Input:
2
10
26
1z2
OUTPUT:
ERROR
INPUT:
2
38762
10
UNWANTED OUTPUT:
201222
I'm not sure from where the computer scans the second num it uses to print the last unwanted output.