There are two newline symbols in the C language: '\n': Insert a newline in a string or text output and move the cursor to the beginning of the next line. "%\n": Escape characters in the format string, replaced by newline characters.
How to use the newline symbol in C language
In C language, there are two commonly used newline symbols :
' \n'
Function: Inserts a newline character in the string or text output and moves the cursor to the beginning of the next line.
Usage:
printf("Hello\nWorld!"); // 输出: // Hello // World!
"%\n"
Function: with '\n ' is the same, but it is an escape character in a formatted string.
Usage:
printf("%%d %%s\n", 10, "Hello"); // 输出: // 10 Hello
Which newline symbol to choose?
In most cases, it is simpler and more convenient to use '\n'. And "%\n" is mainly used when formatting string operations are required.Other notes:
The above is the detailed content of How to use newline symbol in C language. For more information, please follow other related articles on the PHP Chinese website!