Name
endl function template — Manipulator to write an end-of-line character
Synopsis
template <class charT, class traits>
basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
The endl
function template
is a manipulator that writes a newline to os
and then calls os.flush( )
:
std::cout << "Hello, world." << std::endl;
If you do not need to flush the output stream, do not use
endl
; write a plain '\n
' character instead. If you feel you
need to flush the output stream after finishing a line of output,
consider using unit buffering for the stream, or if you need to
flush the output prior to reading an input stream, you can tie the
streams instead of using endl
.
See the basic_ios
class template
(in <ios>
) for information
about tied streams and the ios_base
class (also in <ios>
) for information about unit
buffering.
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.