Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.26 KB

CppStdEndl.md

File metadata and controls

42 lines (30 loc) · 1.26 KB

std::endl is an output stream modifier to go to the next line and flush the stream's buffer.

#include <iostream>  

int main() 
{   
  //Go to next line and flush the std::cout buffer   
  std::cout << std::endl; 
}

The code above is equivalent to the code below [2]:

#include <iostream>  

int main() 
{   
  //Go to next line   
  std::cout << '\n';   
  //Flush the std::cout buffer   
  std::cout.flush(); 
}
  • Avoid std::endl [1,3], as one does not need to flush the std::cout buffer after every output [2].

External links