当前位置:网站首页>Standard C language summary 2
Standard C language summary 2
2022-07-28 07:07:00 【c7473168】
switch Switch branch statement
switch(n) //n It can be a number 、 expression , The result of the operation must be an integer
{
case val:... // If val==n, Then turn on the execution switch ,val Must be constant
//case a ... b Can be said [a,b], But only GNU The compiler supports this syntax , Not recommended
break; // Turn off the actuator switch , end switch,
// If each case all break, Formed a branch structure
//switch Cannot be used in continue coordination
default: // If all case It didn't open , Then finally open default,
// And it can be finally opened in any position
}
for Loop statement
for([1];[2];[3])
{
[4]
}
[1]、 Assign initial values to cyclic variables , But only C99 The above criteria can define the cyclic variable here -std=gnu99
[2]、 Determine whether the loop variable reaches the boundary , If it doesn't arrive , Into the loop
[4]、 Code that is executed repeatedly , It is called circulatory body
[3]、 Change the loop variables , Prevent dead cycle , Generally, cyclic variables are self added 、 Self reduction
1、2、4、3、2、4、3 ...
for(;;) // Dead cycle usage
Brace question :
1、 It is recommended to align up and down
2、 If there is only one line of code in the loop body , Braces can be omitted but are not conducive to expansion
General business codes require that braces should not be omitted
while Loop statement
while( expression )
{
// The loop body
}
do while Loop statement
do{
// The loop body
}while( expression );// The expression continues with a true loop , False to end the loop
Type conversion
Only data of the same type can be operated , If the data of different types needs to be converted to the same type first
recompute
Automatic type conversion :
Conversion rules : On the basis of not losing data , Some space can be sacrificed appropriately
1、 Less bytes to more bytes
2、 Signed to unsigned
3、 Integer to floating point
Be careful : char short When calculating with different types of data ,
Will be promoted to int Participate in the operation after type
Cast :
( New type name ) data ;
Data may be lost in this way , Careful use
边栏推荐
猜你喜欢
随机推荐
Implementation method of Bert
MOOC翁恺C语言第七周:数组运算:1.数组运算2.搜索3.排序初步
The.Joernindex database has no content after Joern runs
MOOC翁恺C语言第五周:1.循环控制2.多重循环3.循环应用
RAID disk array
232(母)转422(公)
Esxi community network card driver updated again
Remotely access the local website of services such as neo4j on the ECS
Erudite Valley Learning Records] Super summary, attentive sharing | common APIs
Reptile learning summary
MOOC翁恺C语言 第四周:进一步的判断与循环:1.逻辑类型与运算2.级联和嵌套的判断
joern运行后.joernindex数据库无内容
MySQL build database Series (I) -- download MySQL
Custom components -- slots
Icc2 analysis timing artifact analyze_ design_ violations
Result number of filled briquettes
VLAN的配置
MOOC翁恺 C语言 第三周:判断与循环:1.判断
DOM window related data, operations & BOM operations
Use powercli to create a custom esxi ISO image








