http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scanf function



============================================================
Email. It's the efficient, easy way to get ALL the
information we need. Now if only there was an easy way to
manage it... There is! It's friendly, fun, and FREE at
http://click.topica.com/caaabBAbUrGczbU68iFa/register
============================================================

I'm not too sure where you can find it. . . check your compiler
documentation.  MSDN might be a good resource.  I haven't looked into it too
much though :)

~Greg


----- Original Message -----
From: russ <nupc@nupc.org>
To: <gameprogrammer@topica.com>
Sent: Saturday, March 31, 2001 12:17 PM
Subject: Re: scanf function


> ============================================================
> Maximize your email efficiency with My Topica. Searchable
> archives, vacation options, and more. Sign up now at
> http://click.topica.com/caaabBDbUrGczbU6XLXa/register
> ============================================================
>
> THANK you!  that did the trick.  do you know a place online that i can
> read about this scanf() function, i would like to understand better the
> first argument string of this function (eg. "%c%*c")  thanks!
>
> russ
>
>
> > scanf("%c%*c", &c);
> >
> > That should do it.
> >
> > The * is an assignment suppression, so it reads in the '\n', but doesn't
> > store it to a variable.
> > You might want to experiment w/ fflush(stdin) too.
> >
> > Hope this helps :)
> >
> > ~Greg
> >
> > > hi gang,
> > >
> > > ok, here's the general code:
> > >
> > > do
> > > {
> > > char choice;
> > > printf( "Enter 'a', 'q', or 'f': " );
> > > scanf( "%c" &choice );
> > > printf( "Your choice was: %c", choice );
> > > if( choice == 'a' ) ...
> > > if( choice == 'f' ) ...
> > > }while (choice != 'q' )
> > > printf( "Finished" );
> > >
> > > the problem is when i go through this loop it goes through it twice
> > > because on scanf() it takes the char as input AND the newline (ie
'\n').
> > >
> > > so an example output would be:
> > >
> > > Enter 'a', 'q', or 'f': e
> > > Your choice was: e
> > > Enter 'a', 'q', or 'f':       <- the input is the newline from the "e"
> > > Your choice was:              <- output is the newline ("\n")
> > >
> > > Enter 'a', 'q', or 'f': q
> > > Finished
> > >
> > > now how can i have the input be JUST the "e" and not the newline "\n"?
> > > thanks for anyhelp, this problem has given me much fuss.
> > >
> > > russ
>
>
>

==^================================================================
EASY UNSUBSCRIBE click here: http://topica.com/u/?bUrGcz.bU68iF
Or send an email To: gameprogrammer-unsubscribe@topica.com
This email was sent to: list@pendleton.com

T O P I C A  -- Learn More. Surf Less.
Newsletters, Tips and Discussions on Topics You Choose.
http://www.topica.com/partner/tag01
==^================================================================