• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Basic Xcode C Lang question...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • RE: Basic Xcode C Lang question...
      • From: "Bill Lowrey" <email@hidden>
  • Prev by Date: Basic Xcode C Lang question...
  • Next by Date: RE: Basic Xcode C Lang question...
  • Previous by thread: Re: Basic Xcode C Lang question...
  • Next by thread: RE: Basic Xcode C Lang question...
  • Index(es):
    • Date
    • Thread