• 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: Problem with 'scanf'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with 'scanf'


  • Subject: Re: Problem with 'scanf'
  • From: "Stephen C. Gilardi" <email@hidden>
  • Date: Thu, 26 Sep 2002 19:00:29 -0400

According to "man setvbuf", stdout should be line buffered and when it
is, the rest of your code works as you probably expect.

Here's the relevant quote:

Normally all files are block buffered. When the first I/O
operation
occurs on a file, malloc(3) is called, and an optimally-sized
buffer is
obtained. If a stream refers to a terminal (as stdout normally
does) it
is line buffered. The standard error stream stderr is always
unbuffered.

I believe it's a bug in Project Builder that the stdout stream that it
implements is not line buffered. Its I/O window is effectively acting
as a terminal.

Pending a possible fix for that bug, you can modify your code to
explicitly set stdout to be line buffered by adding this line:

setlinebuf(stdout);

to the beginning of your program.

I'll file a bug report against Project Builder suggesting that its
stdout be changed to be line buffered.

Note that you will need to explicitly click in the content area of the
"Run" tab in Project builder before your input from the keyboard will
be accepted.

--Squeegee

On Thursday, September 26, 2002, at 01:34 PM, Jean-Baptiste Le Stang
wrote:

> I don't know if it's the right place to post this, but can someone
> tell me
> why this in Project Builder is not running as it should. Thanks
>
> JB (who is trying to learn C before Obj-C)
>
> #include <stdio.h>
>
> int main () {
> int n1,n2;
> printf("Enter a number\n");
> scanf("%d",&n1);
> printf("Enter a number\n");
> scanf("%d",&n2);
> return 0;
> }
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Problem with 'scanf' (From: Jean-Baptiste Le Stang <email@hidden>)

  • Prev by Date: AddressBook: ABPerson "type"
  • Next by Date: Re: Menu when click on table cell
  • Previous by thread: Problem with 'scanf'
  • Next by thread: Re: Problem with 'scanf'
  • Index(es):
    • Date
    • Thread