|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] scanf function
--- Sponsor's Message -------------------------------------- Need Tech Help? Fret no more. Get quick answers on our Q&A tech forum! http://click.topica.com/caaaa4NbUrGczbU68iFa/rebootmypc ------------------------------------------------------------ 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 -- www.russelldsmith.freeservers.com ==^================================================================ 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 ==^================================================================
|
|