I have the following code, i wanted to terminate the while loop if any key except 1 & 2
is press. but only do
executes once. and not while
. why my while condition
is always false. please guide:
char a;
do
{
printf("To Enter the Employee sales press 1 \n");
printf("To Add more items press 2 \n ");
printf("Press any key to Terminate \n\n");
scanf("%c", &a);
if ( a == '1' )
{
printf("1 is presed ");
}
else if(a == '2')
{
int c;
printf("entre Value:");
scanf("%d",&c);
printf("\n");
addItem( &myArray, &size, c );
printitems(myArray, size);
}
}while(a == '1' || a == '2');
Edit So sorry, it was in single qout. i forgot to put the latest code. Even with qoutes it does not run while.