当前位置:网站首页>You Li takes you to talk about C language 7 (define constants and macros)
You Li takes you to talk about C language 7 (define constants and macros)
2022-07-05 04:24:00 【Lu Youli】
Print shaping
#define MAX 1000;
int main()
{
int a = MAX;
printf("%d\n", a);
return 0;
}
Print string
#define TAL "hi,bro!"
int main()
{
printf("%s\n", TAL);
return 0;
}
#define Defining macro
Before, we used the method of function to get the larger value between two numbers , Let's review again
Function implementation
int get_max(int x, int y)
{
int z = 0;
z = (x > y ? x : y);
return z;
}
int main()
{
int a = 50;
int b = 30;
int m = get_max(a ,b);
printf(" Larger value :%d\n", m);
return 0;
}
#define Realization
// When defining a macro , Macro names are generally capitalized
#define MAX(x, y) (x>y?x:y)
int main()
{
int a = 50;
int b = 30;
int m = MAX(a, b);
printf(" Larger value :%d\n", m);
return 0;
}
边栏推荐
猜你喜欢
【UNIAPP】系统热更新实现思路
C26451: arithmetic overflow: use the operator * on a 4-byte value, and then convert the result to an 8-byte value. To avoid overflow, cast the value to wide type before calling the operator * (io.2)
[phantom engine UE] only six steps are needed to realize the deployment of ue5 pixel stream and avoid detours! (the principles of 4.26 and 4.27 are similar)
Burpsuite grabs app packets
Moco is not suitable for target detection? MsrA proposes object level comparative learning target detection pre training method SOCO! Performance SOTA! (NeurIPS 2021)...
[thingsboard] how to replace the homepage logo
直播預告 | 容器服務 ACK 彈性預測最佳實踐
Function (error prone)
【thingsboard】替换首页logo的方法
蛇形矩阵
随机推荐
Components in protective circuit
Threejs loads the city obj model, loads the character gltf model, and tweetjs realizes the movement of characters according to the planned route
【虚幻引擎UE】实现UE5像素流部署仅需六步操作少走弯路!(4.26和4.27原理类似)
This is an age of uncertainty
TPG x AIDU | AI leading talent recruitment plan in progress!
【thingsboard】替换首页logo的方法
Interview related high-frequency algorithm test site 3
MySQL: view with subquery in the from clause limit
Network layer - forwarding (IP, ARP, DCHP, ICMP, network layer addressing, network address translation)
[phantom engine UE] realize the animation production of mapping tripod deployment
函數(易錯)
揭秘技术 Leader 必备的七大清奇脑回路
取余操作是一个哈希函数
【UNIAPP】系统热更新实现思路
Threejs implements labels and displays labels with custom styles
Threejs realizes sky box, panoramic scene, ground grass
机器学习 --- 决策树
Burpsuite grabs app packets
如何进行「小步重构」?
Power management bus (pmbus)