用sizeof()编写的任何内容都不会在C中执行
sizeof函数(有时称为运算符)用于计算给定参数的大小。如果给定其他一些函数作为参数,则不会以sizeof执行该函数。
在下面的示例中,我们将printf()在循环中放入一条语句。然后,我们将看到输出。
示例
#include<stdio.h>
double my_function() {
printf("This is a test function");
return 123456789;
}
main() {
int x;
x = sizeof(printf("Hello World"));
printf("The size: %d\n", x);
x = sizeof(my_function());
printf("The size: %d", x);
}输出结果
The size: 4 The size: 8
在printf()不执行其存在内部的sizeof()。仅考虑返回类型,并采用其大小。
热门推荐
10 诗词送行祝福语大全简短
11 新房开工吉日祝福语简短
12 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短