当前位置:网站首页>Summary of the third class
Summary of the third class
2022-07-05 15:25:00 【Houli crab 670】
The operator
Monocular operators
There are many monocular operators , Here are just a few explanations
- sizeof
It can calculate types and variables , Such asprintf("%d\n",sizeof(int));printf("%d\n",sizeof(a));
This can be calculated , The result of running is 4( Define an integer variable a). - ++a,a++
Novices of this monocular operator often get confused , Or you don't understand the principle thoroughly , But with the accumulation of time, this kind of thing goes directly to the back , I don't think we need to go too deep , All in all , To sum up, the following two sentences .
In front of ++, First add , After use
After ++, First use , Add after
- Cast
Think of this situation , The system will have an alarm , Because it was originally a decimal , And you have to assign it to the variable of shaping , So report a mistake , Then how to solve ?
At this time, the cast type appears
This "(int)“ It means to put 3.252 Cast to Int type .
Only one more ”(int)", So the warning is gone , Does it work ?
Relational operator
What we should pay attention to here is "=“ and ”= =“ The difference between , Novices often make mistakes , I sometimes neglect it carelessly , If it is ignored, the result will be different from that expected .
The result we want to run is "eiei”, But the result is "heihei", At first glance, there seems to be no mistake , And the mistake is "=“ and ”= =“ The difference between , One is assignment , One is equal . Think about the expected results , Just think of the following .
therefore , Make a distinction between ”=“ and ”= =" The difference between .
Logical operators
There is no further study here “ Short circuit phenomenon ”( That's what our school teacher said in class ), Simply put
“&&” : If "&&“ The previous expression is false , that ”&&“ The following expression is not executed , If the following expression has assignment or other operations on variables , Then you won't be able to calculate , It will deviate from the expected results .
“||” : If ”||“ The previous expression is true , So the same ”||" The following expression will not operate , If the following expression also has the operation on variables , Then I can't calculate , There will be deviations .
This is something that some people who are good at learning programs sometimes don't notice , This leads to program errors .
Conditional operators
The conditional operator is also called the trinocular operator , yes C The only ternary operator in language , The usage is also very simple .
(exp It means expression )exp1 Set up ? Set up and Export exp2, Otherwise output exp3.
Comma expression
The comma expression is (exp1,exp2,exp3,…) Its principle is to calculate from left to right , But the result of the whole comma expression is the result of the last expression . Such as :
The result of the operation is 4
First calculate from left to right ,(c=3,b=13,d=4,4) This is how the program works , Take a look .
as for c Why did it start with 3, And then 4, This is what I said at the beginning of my article
First use , Add after
Common keywords
There are many common keywords , I won't list them one by one here , Quarks can be found on a search , Only a few keywords are described here .
- typedef
This is actually type define( The type definition ), Simply put, it is to redefine a type , Its purpose is to simplify the name of complex types , There are other people who do not adapt to this type of name can replace the name . For example, one who doesn't learn C Language people , In his language, plastic surgery is not called int, Then he can redefine .
like this , Is to redefine .
Here is the general "unsigned int" Defined as "uint", Is it a lot simpler ?
typedef+ Space + Defined type + The name of the definition
static
As shown in the figure ,static There are three usages that are not explained in depth here , Explain it in a special article .extern
Declare external symbols ( External symbols are in other source files )
Again and without further explanation , and static Put them together in an article to explain .
边栏推荐
猜你喜欢
Ctfshow web entry information collection
Install and configure Jenkins
Ten billion massage machine blue ocean, difficult to be a giant
爱可可AI前沿推介(7.5)
Bugku's Ah Da
Fr exercise topic --- comprehensive question
计算中间件 Apache Linkis参数解读
Detailed explanation of QT creator breakpoint debugger
Bugku's Eval
I include of spring and Autumn
随机推荐
P1451 calculate the number of cells / 1329: [example 8.2] cells
How can I quickly check whether there is an error after FreeSurfer runs Recon all—— Core command tail redirection
Behind the ultra clear image quality of NBA Live Broadcast: an in-depth interpretation of Alibaba cloud video cloud "narrowband HD 2.0" technology
Bugku's Eval
市值蒸发超百亿美元,“全球IoT云平台第一股”赴港求生
Common redis data types and application scenarios
NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
JS knowledge points-01
Stm32+bh1750 photosensitive sensor obtains light intensity
lv_font_conv离线转换
I spring and autumn blasting-2
Select sort and bubble sort
Coding devsecops helps financial enterprises run out of digital acceleration
Mongdb learning notes
Photoshop plug-in action related concepts actionlist actiondescriptor actionlist action execution load call delete PS plug-in development
Reconnaissance des caractères easycr
JS topic - console log()
Go learning ----- relevant knowledge of JWT
Common interview questions about swoole
Severlet learning foundation