[comp.lang.c++] flush

gjditchfield@watrose.UUCP (12/13/86)

The following program results in an error message from cc (not CC).

#include <stream.h>
main() {
    char c;
    while ( cin.get(c) ) cout << c;
    cout.flush();
    }

cc claims that line 5 (cout.flush()) is an illegal function. Help!
-- 
-------------------------------------------------------------------------------
Glen Ditchfield                      {watmath,utzoo,ihnp4}!watrose!gjditchfield
Dept of Computer Science, U of Waterloo         (519) 885-1211 x6658
Waterloo, Ontario, Canada
"Flame not, lest thou be singed" - Mr. Protocol

bs@alice.UUCP (12/15/86)

In article <8327@watrose.UUCP>, gjditchfield@watrose.UUCP writes:
> The following program results in an error message from cc (not CC).
> 
> #include <stream.h>
> main() {
>     char c;
>     while ( cin.get(c) ) cout << c;
>     cout.flush();
>     }
> 
> cc claims that line 5 (cout.flush()) is an illegal function. Help!
> -- 

Curious. It compiled and ran here.
I think you will have to look for a bug in your port.

There is, however, two observations I can make:

(1) the explicit call of flush is redundant since the ostream destructor
	will be called implicitly for cout, and it will do the flush.

(2) are you really trying to write a program that converts a stream of
	characters into a stream of digits (the digits in the integer
	representation of the characters)? In ``cout << c;'' ``c'' is
	implicitly converted to an integer. The character by character
	copy program looks something like this:

	main()
	{
		char c;
		while (cin.get(c)) cout.put(c);
	}