Path: utzoo!attcan!uunet!mcsun!ukc!axion!masalla.fulcrum.bt.co.uk!sie From: S.J.Raybould@fulcrum.bt.co.uk (Simon Raybould) Newsgroups: comp.sys.amiga Subject: Re: program question, stdin, stdout. Message-ID: <7N6$5X*@masalla.fulcrum.bt.co.uk> Date: 1 Aug 90 12:09:01 GMT References: <2033@bnlux0.bnl.gov> <573@oregon.oacis.org> Sender: root@fulcrum.bt.co.uk (Root on Masalla) Organization: BT Fulcrum, Birmingham Lines: 27 Disclaimer: Organisation given for identification purposes only In article <573@oregon.oacis.org> jmeissen@oregon.oacis.org ( Staff OACIS) writes: >>When I replace putchar with printf("%d\n",c) the program works as I woud > >Yes, the problem is that by default stdout is buffered. When you call putchar() (a macro, >I think) it merely puts characters into a buffer until the buffer fills up, then it gets This is the normal operation of stdio. >flushed. printf() gets around this problem by calling fflush() each time it gets called. RUBBISH!!! printf() doesn't call fflush() each time it is called. The above example works because there is a newline at the end which WILL cause printf() to flush the stdio buffer. printf() uses stdio and will flush the same as all other stdio functions i.e. when the buffer is full or a forwarding condition is met such as \n. SJR +-=-=-=-=-=-=-=-=-=-=-=-=-=-=+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+ | British Telecom Fulcrum | name : Simon John Raybould {^.^} | | Fordrough Lane | path : sie@fulcrum.bt.co.uk \~/ | | Birmingham +-----------+--------------------------| | B9 5LD | // | AMIGA B2000HD 3MB 8088BB | | ENGLAND | \X/AMIGA | Lattice C V5.05 | +-=-=-=-=-=-=-=-=-=-=-=-=-=-=+=-=-=-=-=-=+=-=-=-=-=-=-=-=-=-=-=-=-=-+