[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

Chapter 14.

 

27.3 Standard Iostream Objects



The include header <iostream> declared input and output stream objects. The declared objects are associated with the standard C streams provided for by the functions in <cstdio>.


Overview of Standard Input and Output Stream Objects.

The ANSI/ISO standard calls for predetermined objects for standard input, output, logging and error reporting. This is initialized for normal and wide character formats.


Header <iostream>

Declaration of standard objects

Prototype:

Header <iostream>


namespace std{


extern istream cin;


extern ostream cout;


extern ostream cerr;


extern ostream clog;



extern wistream wcin;


extern wostream wcout;


extern wostream cerr;


extern wostream wclog;


}

Additional topics are:


Stream Buffering

All streams are buffered (by default) except cerr and wcerr.


NOTE

You can change the buffering characteristic of a stream with:


  cout.setf(ios_base::unitbuf);   or
  cerr.unsetf(ios_base::unitbuf);

 


27.3.1 Narrow stream objects

Narrow stream objects provide unbuffered input and output associated with standard input and output declared in <cstdio>.


istream cin

An unbuffered input stream.

Prototype:

istream cin;
Remarks:

The object cin controls input from an unbuffered stream buffer associated with stdin declared in <cstdio>. After cin is initialized cin.tie() returns cout.

Return:

An istream object;


ostream cout

An unbuffered output stream.

Prototype:

ostream cout;
Remarks:

The object cout controls output to an unbuffered stream buffer associated with stdout declared in <cstdio>.

Return:

An ostream object;


ostream cerr

Controls output to an unbuffered stream.

Prototype:

ostream cerr;
Remarks:

The object cerr controls output to an unbuffered stream buffer associated with stderr declared in <cstdio>. After err is initialized, err.flags() and unitbuf is nonzero.

Return:

An ostream object;


ostream clog

Controls output to a stream buffer.

Prototype:

ostream clog;
Remarks:

The object clog controls output to a stream buffer associated with cerr declared in <cstdio>.

Return:

An ostream object;


27.3.2 Wide stream objects

Narrow stream objects provide unbuffered input and output associated with standard input and output declared in <cstdio>.


istream wcin

An unbuffered input stream.

Prototype:

wistream wcin;
Remarks:

The object win controls input from an unbuffered stream buffer associated with stdin declared in <cstdio>. After cin is initialized win.tie() returns wout.

Return:

An wistream object;


ostream wcout

An unbuffered output stream.

Prototype:

wostream wcout;
Remarks:

The object cout controls output to an unbuffered stream buffer associated with stdout declared in <cstdio>.

Return:

An wostream object;


wostream wcerr

Controls output to an unbuffered stream.

Prototype:

wostream wcerr;
Remarks:

The object werr controls output to an unbuffered stream buffer associated with stderr declared in <cstdio>. After werr is initialized, werr.flags() and unitbuf is nonzero.

Return:

An ostream object;


wostream wlcog

Controls output to a stream buffer.

Prototype:

wostream wclog;
Remarks:

The object wlog controls output to a stream buffer associated with cerr declared in <cstdio>.

Return:

An ostream object

 

 


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: July 21, 2000