CPP Manipulators:
Manipulators in C++ are used to modify the output steams. It is most commonly used with insertion operator to modify hte results. The commonly used manipulators are endl, setw and setfill. These manipulators are part of standard namespace. It means we have to write using namespaace befor using these manipulators in our program or have to write scope of std object before manipulators.
endl manipulator:
endl manipulator is used in output statement it's purpose is similar to \n escape sequence. Whenever this manipulator is used with cout object it put a return (new line) in output. The new output will be displayed in next line. We can use endl manipulator multiple times as per requirement with std::cout statement.
endl Example:
#include <iostream>
int main() {
std::cout<<"Hello"<<std::endl<<"World";
return 0;
}
Output:
The above lines of code will print Hello and then change line (insert new line in output), Then print world.
Hello
World
--------------------------------
Process exited after 0.01786 seconds with return value 0
Press any key to continue . . .