在C/C++中,sizeof()运算符用于查找日期类型或变量的大小。永远不会执行用sizeof()编写的表达式。
null
例如:
// C program to demonstrate that the // expressions written in sizeof() are // never executed #include <stdio.h> int main(){ // The printf in sizeof is not executed // Only the return type of printf is // considered and its size is evaluated // by sizeof, int a = sizeof ( printf ( "hey" )); printf ( "%d" , a); return 0; } |
Output: 4
即使我们在sizeof()中指定了一个值,这些更改也不会反映出来。
// One more C program to demonstrate that // the expressions written in sizeof() are // never executed #include <stdio.h> int main() { int a = 5; int b = sizeof (a = 6); printf ( "a = %d, b = %d" , a, b); return 0; } |
Output: a = 5, b = 4
本文由 西祖·辛格 .如果你喜欢GeekSforgek,并想贡献自己的力量,你也可以使用 贡献极客。组织 或者把你的文章寄到contribute@geeksforgeeks.org.看到你的文章出现在Geeksforgeks主页上,并帮助其他极客。
如果您发现任何不正确的地方,或者您想分享有关上述主题的更多信息,请写下评论。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END