🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Stephen J. Muir Sun, 17 Aug 1986 23:16
Streams: line-by-line mode and flushing.
#290
Author: Stephen J. Muir
Date: Sun, 17 Aug 1986 23:16
29 lines
1588 bytes
I wanted to write a routine which would read one file and write another, a line
at a time.  I was rather annoyed to find that the "get" routine for "istream"s
left the '\n' in the stream instead of skipping past it.  Surely, if I want to
read a line at a time, I'm not interested in the line terminator (which I
*know* the value of because I have, implicitly or otherwise, specified it).

Anyway, I wrote a quick test program and found, to my annoyance, that each
output line appears the line after I expected it to.  Here is what I wrote:

# include <stream.h>

char	buf [82];

main ()
{	while (cin.get (buf, 80))
	{	char	c;
		cin.get (c);
		cout << buf << "\n";
	}
}

In desperation, I put a "cout.flush();" after line 9, which didn't help.

C++ Version 1.1, BSD 4.2, VAX-11/750.
-- 
EMAIL:	stephen@comp.lancs.ac.uk	| Post: University of Lancaster,
UUCP:	...!mcvax!ukc!dcl-cs!stephen	|	Department of Computing,
Phone:	+44 524 65201 Ext. 4120		|	Bailrigg, Lancaster, UK.
Project:Alvey ECLIPSE Distribution	|	LA1 4YR
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads