在 C 中,写进 sizeof() 中的任何东西都不会被执行
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
", x);
x = sizeof(my_function());
printf("The size: %d", x);
}输出
The size: 4 The size: 8
printf() 不会被执行,它存在于 sizeof() 中。只有返回类型被考虑,并且它的尺寸被采用。
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP