用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 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短