C + + is an intermediate language, which was designed and developed by Bjarne Stroustrup in Bell Labs in 1979. C + + is an object-oriented programming language, which further expands and perfects C language. C + + can run on a variety of platforms, such as windows, Mac operating system and various versions of UNIX.
using namespace std;
cout << “Hello,Word!” << end1;
You can replace end1 in the above code with “\ n”.
What’s the difference between “\ n” and end1 in C + +?
“\ n” represents a string whose content is a carriage return. STD:: end1 is a stream operator. The function of output is similar to that of output “\ n”, but it may be slightly different. STD:: end1 outputs a newline character and immediately flushes the buffer.
std::cout << std::end1;
std::cout << ‘\n’ << std::flush;
std::cout << ‘\n’ ; std::fflush(stdount);
Because of the stream operator<
For output buffered streams (such as cout and clog), if the buffer is not refreshed manually, the output will be refreshed automatically when the buffer is full. However, for cout (relative to file output stream, etc.), buffering is not obvious. But it’s a good habit to use end1 instead of ‘\ n’ if necessary. For unbuffered streams (such as cerr of standard error output), refresh is unnecessary. You can directly use “\ n”.