当前位置:网站首页>C language: Escape Character

C language: Escape Character

2022-07-25 03:57:00 Code Knight

about ASCII code ,0~31( Decimal system ) The characters in the range are control characters , They are invisible , Cannot be displayed on the display , You can't even type... From the keyboard , Can only be expressed in the form of escape characters . however , Use it directly ASCII Code memory is inconvenient , It's not easy to understand , therefore , For common control characters ,C Language also defines abbreviations , The complete list is as follows :

Escape character significance ASCII Code value ( Decimal system )
\a Ring the bell (BEL)007
\b Backspace (BS) , Move the current position to the previous column 008
\f Change the page (FF), Move the current position to the beginning of the next page 012
\n Line break (LF) , Moves the current position to the beginning of the next line 010
\r enter (CR) , Move the current position to the beginning of the line 013
\t Horizontal TAB (HT) 009
\v Vertical tabulation (VT)011
\' Single quotation marks 039
\" Double quotes 034
\\ The backslash 092


\n and \t Are the two most commonly used escape characters :

  • \n Used to wrap lines , Let the text output from the beginning of the next line , It has been used many times in the previous chapters ;
  • \t Used for occupying , Generally equivalent to four spaces , perhaps tab Key function .


Single quotation marks 、 Double quotes 、 Backslashes are special characters , Can't express directly :

  • Single quotation marks are the beginning and end of character types , To use \' Express , That is to say '\'';
  • Double quotes are the beginning and end of a string , To use \" Express , That is to say "abc\"123";
  • The backslash is the beginning of the escape character , To use \\ Express , That is to say '\\', perhaps "abc\\123".
原网站

版权声明
本文为[Code Knight]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/201/202207192116193748.html