当前位置:网站首页>C language character constant
C language character constant
2022-04-23 03:56:00 【Floating】
Doing it C The problem of character constant recognition is encountered in the process of language lexical analyzer . Here we discuss the lexical rules of general character constants , Do not design wide characters and general characters .
character constants
C A language character constant consists of one or more characters contained in single quotes , When multiple characters are included, the specific value is related to the compiler ( such as VS2019 The compiler is to get the last character ). Such as :‘a’ ‘XY’ ‘0’ ‘*’
All characters in the source code character set can become character constants , Except for single quotes 、 Backslashes and line breaks , These three characters must be represented by escape characters :‘\’’ ‘\’ ‘\n’ . In the compilation phase , The characters and escape sequences in character constants and string literals are converted to the corresponding characters in the running character set .
Type and value of character constant
For all non wide character constants , The type is int, namely C There is no difference between character constants and integers in languages , It can be mixed up . The following code can run normally .
int a = 'P';char c = 80;
Here's the thing , If signed char type , Then the value of the character constant can be negative , as follows :
int c = '\xA3';
printf("%c %d\r\n",c,c);
The result is £ -93 May adopt unsigned char Such values are positive
Escape character
Escape sequences | Character value | Actions on output devices |
---|---|---|
\’ | Single quotation marks | The output characters |
\" | Double quotes | The output characters |
\? | question mark | The output characters |
\\ | Backslash | The output characters |
\a | Warning | Produce sound or visual signals ,windows Error reporting sound |
\b | Backspace | Move one character forward |
\f | Change the page | Move to the beginning of the next page |
\n | Line break | Move to the beginning of the next line |
\r | enter | Move to the beginning of the current line |
\t | Horizontal tabs | Move to the next vertical tab alignment point |
\v | Vertical tabs | Move to the next vertical tab alignment point |
\o,\oo,\ooo o Is an octal character |
This octal corresponds to the character | The output characters |
\xh,\xhh h Is a hexadecimal character |
Sub hexadecimal corresponding character | The output characters |
Refer to the C language norm The second edition
版权声明
本文为[Floating]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230351383995.html
边栏推荐
- 标识符、关键字、数据类型
- Using VBA interval to extract one column from another in Excel
- MATLAB lit plusieurs diagrammes fig et les combine en un seul diagramme (sous forme de sous - Diagramme)
- Counting and sorting (C language implementation) -- learning notes
- QT program integration easyplayer RTSP streaming media player screen flicker what is the reason?
- [latex] differences in the way scores are written
- Now is the best time to empower industrial visual inspection with AI
- Installation and configuration of clion under win10
- Definition, understanding and calculation of significant figures in numerical analysis
- Wechat payment iframe sub page has no response
猜你喜欢
51 single chip microcomputer: D / a digital to analog conversion experiment
Xiaohongshu was exposed to layoffs of 20% as a whole, and the internal volume among large factories was also very serious
Identificateur, mot - clé, type de données
Variables, constants, operators
Process seven state transition diagram
Let matlab2018b support the mex configuration of vs2019
Solve the technical problems in seq2seq + attention machine translation
Detailed explanation on the use of annotation tool via (VGg image annotator) in mask RCNN
Now is the best time to empower industrial visual inspection with AI
[AI vision · quick review of NLP natural language processing papers today, issue 29] Mon, 14 Feb 2022
随机推荐
vscode删除卸载残余
现货黄金操作技巧_估波曲线
Digital image processing third edition Gonzalez notes Chapter 2
【BIM入门实战】Revit建筑墙体:构造、包络、叠层图文详解
Installation and configuration of clion under win10
[AI vision · quick review of today's sound acoustic papers issue 1] Thu, 14 APR 2022
The super large image labels in remote sensing data set are cut into specified sizes and saved into coco data set - target detection
The difference between lists, tuples, dictionaries and collections
Hard core chip removal
中国移动日赚2.85亿很高?其实是5G难带来更多利润,那么钱去哪里了?
Let matlab2018b support the mex configuration of vs2019
Counting and sorting (C language implementation) -- learning notes
Vscode delete uninstall residue
Network principle | connection management mechanism in TCP / IP important protocol and core mechanism
What if you encounter symbols you don't know in mathematical formulas
標識符、關鍵字、數據類型
秒杀所有区间相关问题
MySQL zip installation tutorial
Paddlepaddle model to onnx
创下国产手机在海外市场销量最高纪录的小米,重新关注国内市场