Namespaces
Variants
Views
Actions

std::endl

From cppreference.com
< cpp‎ | io‎ | manip
Revision as of 09:43, 28 December 2011 by Cubbi (Talk | contribs)

Template:cpp/io/manip/sidebar

Defined in header <ostream>
template< class CharT, class Traits >
std::basic_ostream<charT,traits>& endl( std::basic_ostream<CharT, Traits>& os );

Inserts a endline character into the output sequence os and flushes it as if by calling Template:cpp followed by Template:cpp.

This is an output-only I/O manipulator, it may be called with an expression such as Template:cpp for any out of type Template:cpp.

Contents

Notes

This manipulator may be used to produce a line of output immediately, e.g. when displaying output from a long-running process, logging activity of multiple threads or logging activity of a program that may crash unexpectedly. An explicit flush of Template:cpp is also necessary before a call to Template:cpp, if the spawned process performs any screen I/O (a common example is Template:cpp on Windows). In most other usual interactive I/O scenarios, Template:cpp is redundant when used with Template:cpp because any input from Template:cpp, output to Template:cpp, or program termination forces a call to Template:cpp. Use of Template:cpp in place of Template:cpp, encouraged by some sources, may significantly degrade output performance.

The code samples on this wiki follow Bjarne Stroustrup in flushing the standard output only where necessary.

When an incomplete line of output needs to be flushed, the Template:cpp manipulator may be used.

When every character of output needs to be flushed, the Template:cpp manipulator may be used.

Parameters

os - reference to output stream

Return value

os (reference to the stream after manipulation)

Example

Template:example cpp

See also

Template:cpp/io/manip/dcl list unitbufTemplate:cpp/io/manip/dcl list flush