Re: Basic C Language question
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.