#include<stdio.h>
int main()
{
char a;
do {
printf("\n enter letter a,b or c: ");
scanf("%c", &a);
switch (a)
{
case 'a' :
printf("\n one \n");
break;
case 'b' :
printf("\n two \n");
break;
case 'c' :
printf("\n three \n");
break;
default:
printf("\n invalid input \n");
break;
}
}while(a != 'd');
}
this code always runs default even there is a break;
but if u replace %c to %s, it works normally, i just want to understand why using %c does that or is there any other way to make it run perfectly with using %c
also using a=getch() works but i want to display the input without using printf to display it