|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: scanf function
============================================================ Maximize your email efficiency with My Topica. Searchable archives, vacation options, and more. Sign up now at http://click.topica.com/caaabBDbUrGczbU68iFa/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 ==^================================================================
|
|