Re: Basic Xcode C Lang question...
Re: Basic Xcode C Lang question...
- Subject: Re: Basic Xcode C Lang question...
- From: Isaac Rivera <email@hidden>
- Date: Sun, 11 Jul 2004 15:13:08 -0400
On Jul 11, 2004, at 3:03 PM, Creed Erickson wrote:
You're trusting scanf to do what you think it should.
Should it?
printf("Do you want to enter another value? (Y or N): ");
scanf("%c", &answer);
This fragment is picking up the newline character placed in the input
buffer when entering the value.
It doesnt in the previous scanf in the program, why would it here?
This code is exactly reproduced from the Beginning C, 3rd edition by
Ivor Horton book. I know, I know, books have errata. But several of the
examples on chapter 4 revolve around this logic (scanf halting the
execution of a fot loop), Knowing that Mr. Horton knows well how C
should behave, specially a basic io function like scanf, I wonder if
this is a mac implementation issue or what?
Isaac
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.