0
faizulhaque's Avatar, Join Date: May 2008
Skilled contributor
for charachtor
Code:
main();
  char another='y';
  while (another=='y')
  {
    printf("Type Any charactor Except y ");
    another=getche();
  }
}
0
Amit Kumar Saha's Avatar, Join Date: Aug 2008
Go4Expert Member
I have already tried that one. And I am honest. Thank you for your suggestion.
0
faizulhaque's Avatar, Join Date: May 2008
Skilled contributor
what type of probelm u are facing i couldn't get u
0
Amit Kumar Saha's Avatar, Join Date: Aug 2008
Go4Expert Member
The way that you suggested me, exactly in the same way I have tried. but it did not do the trick for me. if I use fflush then it takes a input. But why it does not take without fflush?
0
Amit Kumar Saha's Avatar, Join Date: Aug 2008
Go4Expert Member
can ant body give me code to find out Fibonacci number?

thank you inadvance
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
probably better to start a new thread for a new topic.
0
aditiya's Avatar, Join Date: Aug 2008
Newbie Member
Ur question is not clear.if u want to take a character during the loop then you can take it like this.It is working fine

char ch='Y';
printf("Do U want to continue loop ?Press Y:N");
while(ch=='Y')
{
scanf("%c",&ch);
fflush(stdin);
}
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
You still haven't explained how or why our suggestions don't work.

A shot in the dark: are you asking if it's possible to check the keyboard without stopping the while loop from running? If the problem with scanf is that it stops processing while it waits for input?
0
Chinmoy's Avatar, Join Date: Feb 2008
Light Poster
Scanf reads input overflows from preious input statements. Use scanf with care i would suggest. Or use a space in front of the control string in scanf("%c",...) as scanf(" %c",...). This destroys the previous input buffer.
0
Amit Kumar Saha's Avatar, Join Date: Aug 2008
Go4Expert Member
Your suggestion helped me out a lot thanks.