C++ Logo


Advanced search

Re: is `\n` replacement of `std::endl`

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 26 Jul 2019 09:30:40 -0700
On Thursday, 25 July 2019 19:04:00 PDT Francis Grizzly Smit via Std-Discussion
> On 26/07/2019 11:57, praveer kumar via Std-Discussion wrote:
> > HI Experts,
> > Below is my sample code. I can see there is different time duration
> > captured to process the same data by using "\n", '\n' and std::endl.
> std::endl is basically equivalent to << '\n' << std::flush;

And stdout is line buffered when connected to a TTY (see setvbuf() in the C
library), so it automatically flushes on every '\n'. That means there's no
difference in behaviour.

When connected to a TTY.

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

Received on 2019-07-26 11:32:48