• 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 C Language question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic C Language question


  • Subject: Re: Basic C Language question
  • From: Eric Albert <email@hidden>
  • Date: Sun, 8 Aug 2004 13:31:39 -0700

On Aug 8, 2004, at 1:12 PM, Isaac Rivera wrote:

		// Read a string of up to BUFFER_LEN characters:
		while(((pBuffer - buffer) < BUFFER_LEN - 1) && ((*pBuffer++ =
getchar()) != '\n'));

Shouldn't the last line of code kill the while loop when one types 9
characters in a row?

But it doesn't it keeps on taking imput as long as I don't press ENTER.

See <http://www.eskimo.com/~scs/C-faq/q19.1.html> from the comp.lang.c newsgroup FAQ.


In general, the simplest way to do this in C is to read an entire line and then process the first n characters, or ask the user to type the line again if it was more than n characters long.

Hope this helps,
Eric
_______________________________________________
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.


References: 
 >Basic questions (From: Shawn Somers <email@hidden>)
 >Basic C Language question (From: Isaac Rivera <email@hidden>)

  • Prev by Date: Re: using an external library in an Xcode project
  • Next by Date: Re: using an external library in an Xcode project
  • Previous by thread: Basic C Language question
  • Next by thread: Where's the download link?
  • Index(es):
    • Date
    • Thread