🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #1154

Re: Question and problem with GCC/2

#1154
From: Wen-Chun Ni
Date: Thu, 20 Aug 1992 03:14
73 lines
3047 bytes
If gcc/2 is going to be ANSI-compliant, I think there are something wrong 
here.  According to W Richard Stevens' book "Advanced Programming in the
Unix Environment," pp 123, about "stdio" library:

	ANSI C requires the following buffering characteristics:

	 1. Standard input and standard output are fully buffered, if
	    and only if they do not refer to an interactive device.
	 2. Standard error is never fully buffered.


I've tried all the I/O operations under both SunOS and my Linux and
they comply to the above requirement. While the OS/2 gcc/2 doesn't
seems to get it right. Somebody mentioned that "buffering" was 
supposed to be ANSI-compliant, but I think it's kind of misunderstood.


Wen-Chun Ni

In article <1992Aug20.010531.28610@mdd.comm.mot.com> lmorris@mdd.comm.mot.com (Larry Morris) writes:
>In <1992Aug19.212328.15304@talon.ucs.orst.edu> hilmera@ucs.orst.edu (Andrew Hilmer) writes:
>
>>Compiler: gcc/2 2.1
>>Problem: problem and question about gcc/2
>
>...
>
>>/*
>>  This program takes the input of two numbers, one
>>  integer, one floating point, and prints them back out.
>>*/
>
>>#include <stdio.h>
>
>>main()
>>{
>>  int x;
>>  float y;
>
>>/*  fflush(stdin); */
>>  printf("This is my first C program.\n");
>>  printf("Enter an integer: ");
>>  scanf("%d", &x);
>>  printf("Enter a floating point number: ");
>>  scanf("%f", &y);
>>  printf("The value stored in x is %d\n", x);
>>  printf("The value stored in y is %f\n", y);
>>}
>
>...
>
>>When run, it prints nothing but a line or two and a blinking cursor.
>>As a shot in the dark, I entered 3, hit enter (got another big
>>nothing), then entered 93.9 and hit enter.
>
>Read  the FAQ.  Nothing says when stdout will flush unless you specify it.
>The program did exactly as requested. 
>    printf() some stuff   --  it gets buffered to stdout
>    scanf() some stuff    --  you typed 3
>    printf() some more    --  stdout buffers some more
>    scanf() some more     --  you typed 93.9
>    exit()		-- stdout gets flushed at exit and you see the printfs()
>
>If you want to handle the flushes yourself, just fflush(stdout)  before each
>of the scanfs().  Takes full advantage of any buffering and gets you exactly
>what you want.
>
>
>-- 
>Internet:    <lmorris@mdd.comm.mot.COM>   |  Larry Morris
> ...uw-beaver!sunup-----\                 |  Motorola/Mobile Data Division
> ...uunet-----------------!mdisea!lmorris |  19807 North Creek Parkway
> ...van-bc!mdivax1------/                 |  Bothell, WA  (206) 487-5810
Technical Details
Message-ID: <1992Aug20.031405.20353@cs.brown.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!brunix!brunix!wcn
References: <1992Aug19.212328.15304@talon.ucs.orst.edu> <1992Aug20.010531.28610@mdd.comm.mot.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!brunix!brunix!wcn
From: wcn@cs.brown.edu (Wen-Chun Ni)
Subject: Re: Question and problem with GCC/2
Message-ID: <1992Aug20.031405.20353@cs.brown.edu>
Sender: news@cs.brown.edu
Organization: Brown University Department of Computer Science
References: <1992Aug19.212328.15304@talon.ucs.orst.edu> <1992Aug20.010531.28610@mdd.comm.mot.com>
Distribution: na
Date: Thu, 20 Aug 1992 03:14:05 GMT
Lines: 75