scanf

Go4Expert Member
8Aug2008,13:32   #1
Amit Kumar Saha's Avatar
I want to know scanf statement does not wait for a input in compiler?
or when it takes more input than the fixed number of input??
I use Microsoft visual studio 6.0
Mentor
10Aug2008,21:57   #2
xpi0t0s's Avatar
Could you rephrase the question please, because it doesn't make any sense. scanf gets input from the user, I don't understand what "scanf statement does not wait for a input in compiler" means. scanf doesn't wait for anything from the compiler.

Are you having a problem with some code?
Go4Expert Member
13Aug2008,20:22   #3
Amit Kumar Saha's Avatar
Many thanks. Here is the detailed information.
I am executing a infinite while loop. now I want check a character input to justify whether the user is still interested tu carry on the loop. But here the scanf is not working.
thanking again
Skilled contributor
13Aug2008,23:14   #4
faizulhaque's Avatar
use getche() rather than scanf command for Character inputs.
like

Code:
char ch;
ch=getche();
printf("%c",ch);

Last edited by faizulhaque; 13Aug2008 at 23:30..
Go4Expert Member
14Aug2008,09:28   #5
Amit Kumar Saha's Avatar
Thanks for help.

But I have tried that one. But it still does not work. Is there any other solution?

Thanking you

Amit
Mentor
14Aug2008,13:00   #6
xpi0t0s's Avatar
How exactly doesn't it work? What doesn't it do that you want it to?
Do you want the check for user input to pause the loop, or do you want the loop to continue running while a check for user input is made?
Skilled contributor
14Aug2008,20:36   #7
faizulhaque's Avatar
would u plz give the snap of error command line.
Go4Expert Member
15Aug2008,22:39   #8
Amit Kumar Saha's Avatar
Yes I was trying to check any input to break a infinite while loop.

thank you
Skilled contributor
15Aug2008,22:44   #9
faizulhaque's Avatar
use this
int a=1;
while (a==1)
{
printf("Enter Any Number Accept 1");
scanf("%d",&a);
}

above one is giving u infinit loog but when the user give input 1 than it's terninate.
Go4Expert Member
16Aug2008,00:23   #10
Amit Kumar Saha's Avatar
But I was trying to take input a character in the same way. I have already applied the technique that you suggested for me. But I want to take a character. Is there any way in the same manner??

Thanking you in advance