
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</p><p>", x);
x = sizeof(my_function());
printf("The size: %d", x);
}The size: 4 The size: 8
在sizeof()中,不会执行printf(),只会考虑返回类型,并取其大小。
以上就是在C语言中,任何写在sizeof()中的内容都不会被执行的详细内容,更多请关注php中文网其它相关文章!
C语言怎么学习?C语言怎么入门?C语言在哪学?C语言怎么学才快?不用担心,这里为大家提供了C语言速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号