🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: gnu.g++.lib.bug
1 messages
1 total messages Started by T.Day Sun, 26 Nov 1989 20:04
Reading last thing from an istream
#194
Author: T.Day
Date: Sun, 26 Nov 1989 20:04
28 lines
1022 bytes
From: Tim Day <T.Day@uk.ac.ucl.cs>

// Bug or feature ? In libg++ 1.36 using g++ 1.36.1
// I'm think this behaved differently with libg++ 1.35.  A 2.0ism ?
// The problem is that if the last integer is not followed by whitespace
//  the istream will go bad... I'd expect this to happen only on a subsequent
//  attempt to read

#include <stream.h>

main()
{	unlink("foo");
	
	{ostream foo("foo",io_writeonly,a_create);
	foo << 1 << " " << 2 << " " << 3;// No trailing whitespace after 3
	}

	{istream foo("foo",io_readonly,a_useonly);
	int count=0,n;
	while (foo >> n) {cerr << n << " ";count++;}
	cerr << " : " << count << " integers read\n";
	}

	exit(0);
}

// Outputs :
// 1 2  : 2 integers read
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