Originally Posted by
xhoangx
printf("enter choice: ");
scanf("%d", &choice);
if(choice==1)
do this;
if(choice==2)
do that;
if(choice==(Enter key))
do something;
How can i make so that when the user hits the enter key, it records that as a choice and does whatever is in that if statement, instead of just going to the next line and waiting for a proper input.
please use code tags guys. to post your code.
yes you can do that. sample code
Code:
#include<stdio.h>
int main()
{
int ch;
scanf("%d",&ch);
if(ch==1)
printf(" Block 1 ");
else if(ch==2)
printf(" Block 2");
else if(ch==3)
printf("Block 3");
}
/* my ouput
1
Block 1
*/
ssharish2005