Re: Problem with 'scanf'
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.