Help me solve a scanf problem in a loop

Status
Not open for further replies.

grittinjames

Advanced Member level 1
Joined
Jun 1, 2006
Messages
479
Helped
44
Reputation
90
Reaction score
32
Trophy points
1,308
Location
bangalore india
Activity points
3,985
hai friends

int i=0;

do{

scanf("%d",&i);
printf("%d",i);

while(i>100||i<1);


in this loop if im enternimg a charecter when scanf waiting i will not change it will be 0,
while gety satsfied and again it will move to do ,
but this time scanf is not waiting for entering data ,it becoming an infinite loop

what is the problem
how i can solve it
plz help me
 

Re: scanf is not working

int i=0;

do{

scanf("%d",&i);
printf("%d",i);

8. }while(i>100||i<1);

you forget a close semicolon in the statement 8
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…