gpt4 book ai didi

c - sizeof((int)(float)(char)i)) 当 int 被定义时 (int)(float)(char) i;

转载 作者:太空宇宙 更新时间:2023-11-04 00:55:21 24 4
gpt4 key购买 nike

#include<stdio.h>
double i;

int main()
{
(int)(float)(char) i;
printf("%d", sizeof((int)(float)(char)i));
return 0;
}

以上在微软编译器上输出 4。为什么?

最佳答案

sizeof 是变量的大小(以字节为单位)。在这种情况下,i 被转换为 4 个字节的 int

这些是 MS C++ 上类型的大小:http://msdn.microsoft.com/en-us/library/cc953fe1(v=vs.71).aspx

关于c - sizeof((int)(float)(char)i)) 当 int 被定义时 (int)(float)(char) i;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4678809/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com