Knowledge point 6: escape characters

Escape character

printf("here\v\f");//会输出一个奇奇怪怪的字符

\v,\fThese two escape characters can only be displayed in the printer, and the display screen does not work.

printf("123\b45");//输出1245

\bThe meaning of is backspace, which means to move the cursor to the previous unit.
After outputting 123, the cursor moves forward, and then 45 is printed, 3 is overwritten , so it looks like a deletion

printf("\n1234\b");//输出1234

But when you put \b at the end, because you just moved the cursor and didn't do anything , it looks like it didn't delete

printf("here\rjjj");//输出jjje

\rCarriage return means that the cursor returns to the
beginning of the line. Carriage return is different from line feed. In the
same way, put \r at the end, because there is no effect after only moving the cursor.

printf("\\"); //输出 \ 
printf("%%"); //输出 %

To output \, the code needs to haveTwo'\'
Similarly, if you want to output %, you need to haveTwo ’ % '

printf("\'"); //输出 '
printf("\"");//输出 "

To output separately ', "such characters must be preceded by \,

Any character in the c language can be represented by an escape character
\ddd — Output 1~3 digitsOctalThe character represented by the number
\ xhh — Output 1~2 digitsHexadecimalCharacters represented by numbers
For example:

printf("\101"); //输出A('A'对应的ASCII码为65,对应的八进制为101)
printf("\x41");//输出A('A'对应的ASCII码对应的十六进制为41)

Guess you like

Origin blog.csdn.net/Shao_yihao/article/details/112541118