It appears that when you use the getchar and type the option and enter, it returns the character and a LF. I added some things to yours, and it runs. I type a for the first option, and it prints A for the first option, and then prints 10 (decimal format) of option2. Then enter b for the scanf, and it prints out b Not sure why it is including the LF with the getchar. void main() { char option,option2; printf("Choose an option:"); option=toupper(getchar()); printf("%c\n",option); option2=getchar(); printf("Option2 %d\n",option2); printf("Choose another option:"); scanf("%c",&option); printf("%c\n",option); } On 12 Oct 2004 at 16:44, Vinicius wrote: From: Vinicius <cviniciusm@xxxxxxxxxxxx> To: For users of Fedora Core releases <fedora-list@xxxxxxxxxx> Date sent: Tue, 12 Oct 2004 16:44:24 -0300 Subject: off topic: Doubt about gcc 3.3.3 and ( getchar() or scanf(%s) )? Send reply to: For users of Fedora Core releases <fedora-list@xxxxxxxxxx> <mailto:fedora-list-request@xxxxxxxxxx?subject=unsubscribe> <mailto:fedora-list-request@xxxxxxxxxx?subject=subscribe> > Hello, > > the following code does not work: > " > ... > void main(void) > { > char option; > > printf("Choose an option: "); > > option = toupper(getchar()); > > printf("Chosse another option: "); > > scanf("%c", &option); > > ... > > > It shows "Choose an option: Choose another option ". Why? > Whether I put two lines "fflush(stdin)" before the inputs, the same > above occurs. > > my gcc: "$ gcc --version > gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)" > > TIA, Vinicius. > > P.S.: Where is the best place to put this question, p ease? > > -- > fedora-list mailing list > fedora-list@xxxxxxxxxx > To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list > +----------------------------------------------------------+ Michael D. Setzer II - Computer Science Instructor Guam Community College Computer Center mailto:mikes@xxxxxxxxxxxxxxxx http://www.guam.net/home/mikes Guam - Where America's Day Begins +----------------------------------------------------------+ http://setiathome.berkeley.edu Number of Seti Units Returned: 14,509 Processing time: 29 years, 63 days, 6 hours, 48 minutes (Total Hours: 255,559)