Home >Backend Development >C++ >What does /n mean in c++
/n
in C represents a newline character
In the C programming language, the \n
escape sequence represents a newline character.
Purpose
The newline character is used to move the text content to a new line. It is often used with output operations such as cout
to create new lines in the output.
Representation form
In C, the newline character can be represented in the following two ways:
Usage examples
Consider The following code snippet:
<code class="cpp">#include <iostream> using namespace std; int main() { cout << "Hello" << endl; cout << "World!" << endl; return 0; }</code>
In this example, the endl
stream manipulator (essentially a special string stream containing newlines) is used between "Hello" and "World!" " Create new lines between output statements.
The output result is:
<code>Hello World!</code>
Note
'\r'
escape sequence to represent a carriage return character, which moves the cursor to the beginning of the line without wrapping. The above is the detailed content of What does /n mean in c++. For more information, please follow other related articles on the PHP Chinese website!