当前位置:网站首页>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;
}
边栏推荐
- 直播預告 | 容器服務 ACK 彈性預測最佳實踐
- Sword finger offer 07 Rebuild binary tree
- Rome chain analysis
- How to force activerecord to reload a class- How do I force ActiveRecord to reload a class?
- 函數(易錯)
- [phantom engine UE] the difference between running and starting, and the analysis of common problems
- Threejs rendering obj+mtl model source code, 3D factory model
- Machine learning decision tree
- 解密函数计算异步任务能力之「任务的状态及生命周期管理」
- 北京程序员的真实一天!!!!!
猜你喜欢
直播預告 | 容器服務 ACK 彈性預測最佳實踐
Ctfshow web entry code audit
TPG x AIDU | AI leading talent recruitment plan in progress!
Mxnet imports various libcudarts * so、 libcuda*. So not found
Network security - record web vulnerability fixes
官宣!第三届云原生编程挑战赛正式启动!
【科普】热设计基础知识:5G光器件之散热分析
TPG x AIDU|AI领军人才招募计划进行中!
美国5G Open RAN再遭重大挫败,抗衡中国5G技术的图谋已告失败
Sequence diagram of single sign on Certification Center
随机推荐
Mxnet imports various libcudarts * so、 libcuda*. So not found
Threejs clicks the scene object to obtain object information, and threejs uses raycaster to pick up object information
American 5g open ran suffered another major setback, and its attempt to counter China's 5g technology has failed
Serpentine matrix
Technical tutorial: how to use easydss to push live streaming to qiniu cloud?
Clickpaas low code platform
【thingsboard】替换首页logo的方法
Hexadecimal to octal
Learning notes 8
After the deployment of web resources, the navigator cannot obtain the solution of mediadevices instance (navigator.mediadevices is undefined)
Study notes 7
Realize the attention function of the article in the applet
自动语音识别(ASR)研究综述
SPI read / write flash principle + complete code
包 类 包的作用域
Threejs realizes sky box, panoramic scene, ground grass
取余操作是一个哈希函数
[moteur illusoire UE] il ne faut que six étapes pour réaliser le déploiement du flux de pixels ue5 et éviter les détours! (4.26 et 4.27 principes similaires)
北京程序员的真实一天!!!!!
How to carry out "small step reconstruction"?