C++ Tutorial: endl
Syntax
The endl
is a C++ predefined function, which is used to insert a new line character and flush the output buffer.
std::cout << endl;
Example
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}
Output
The output of the above example will be:
Hello, World!
Explanation
The endl
function is used to insert a new line character and flush the output buffer. This is useful when we want to display output to the console or terminal. Without using the endl
function, the output will be displayed on the same line.
Use
The endl
function is used to insert a new line character and flush the output buffer. It is mainly used to display output to the console or terminal.
Important Points
- The
endl
function is a C++ predefined function. - It is used to insert a new line character and flush the output buffer.
- The
endl
function is mainly used to display output to the console or terminal.
Summary
In this tutorial, we learned about the endl
function in C++. We learned its syntax, example, output, explanation, use, important points, and summary. The endl
function is a useful tool when displaying output to the console or terminal.