when i'm giving some character values followed by an integer the scanf
is not reading the integer

On Sep 13, 1:08 pm, Don <[email protected]> wrote:
> Scanf with a %d flag will ignore anything that is not a decimal
> number, until it finds a decimal number.
> Don
>
> On Sep 13, 5:23 am, Avinash Dharan <[email protected]> wrote:
>
>
>
>
>
>
>
> >  #include <stdio.h>
> > void main()
> > {
> >      while(1)
> >      {
> >         int opt;
> >         scanf("%d",&opt);
> >        printf("%d\n",opt);
> >    }
>
> > }
>
> > when i execute this program, if i give a character instead of an integer, it
> > goes into an infinite loop. why is it so?

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to