In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
The knowledge points of this article "how to use C language escape characters" are not quite understood by most people, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article, let's take a look at this article "how to use C language escape characters" article.
1. Escape character\ t.
Code snippet 1:
# includeint main () {printf ("c:\ test\ test.c"); return 0;}
"\" and "t" form an escape character "\ t".
Escape character: changes the original meaning.
two。 Escape character\ n.
Code snippet 2:
# includeint main () {printf ("ab\ ncd"); return 0;}
The combination of "\" and "n" changes the original meaning, the meaning of line change.
3. Escape character\?
Write more than one? To prevent them from being parsed into three-letter words.
Code snippet 3:
# includeint main () {printf ("(are you ok??)") ; / /?) --]-three-letter word}
The old compiler?) Will be parsed into].
Code snippet 4:
# includeint main () {printf ("(are you ok\?)") ; return 0;}
Output result:
(are you ok)
The old compiler outputs the result:
(are you ok)
4. Escape character\'.
Used to represent character constants.
Code snippet 5:
# includeint main () {printf ("% c\ n",'a'); return 0;}
Output result:
A
Code snippet 6:
# includeint main () {printf ("% c\ n",''); return 0;}
The two single quotation marks of the output statement of this code are wide by one unit number. The first two single quotation marks are considered to be single quotation marks in a pair of single quotation marks, and the last one is left alone. Add a\ to escape (\') before the single quotation mark, and it is no longer a pair of single quotation marks with a single quotation mark but with this transfer character.
Code snippet 7:
# includeint main () {printf ("% c\ n",'\'); return 0;}
Output result:
'
5. Escape character\'.
Used to represent double quotation marks inside a string.
Code snippet 7:
# includeint main () {printf ("% c\ n", "\"); return 0;}
Output result:
''
6. Escape character\,\ t.
\\ is used to represent a backslash to prevent it from being interpreted as an escape sequence.
Code snippet 8:
# includeint main () {printf ("c:\\ test\\ test.c"); return 0;}
Output result:
Because\ t is a transfer character that cannot be printed, adding a\ becomes\\ test.
\ t is a horizontal tab (keyboard tapkey).
Code snippet 9:
# includeint main () {printf ("c:\ test\ test.c"); return 0;}
Output result:
7. Escape characters\ a,\ b,\ f,\ n,\ r,\ v.
\ a warning character (beep)
\ b backspace character
\ F Feed character
\ nWrap
\ r enter
\ v Vertical tab character
8. Escape character\ ddd
Three d represents one to three octal digits. Such as\ 130X
Code snippet 10:
# includeint main () {printf ("% c\ n",'\ 130'); return 0;}
Output result:
How much is the octal 130 in decimal?
What about the decimal 130?
Code snippet 11:
# includeint main () {printf ("% c\ n",'\ 101'); / / A-ASCII value is 65, octal is 101 return 0;} 9. Escape character\ xdd.
Dd represents two hexadecimal digits. For example:\ x300
Code snippet 12:
# includeint main () {printf ("% c\ n",'\ x30'); return 0;}
Output result:
10. Exercise to find the length of a string
Code snippet 13:
# includeint main () {printf ("% d\ n", strlen ("c:\ test\ 328\ test.c"); return 0;}
The length of the code string is 14.
"c:\ t e s t\ 328\ t e s t. C"
The above is about the content of this article "how to use C language escape characters". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.