什么是输出? [英] What will be the Output ?

查看:103
本文介绍了什么是输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

struct x
{
int i;
char c;
}

union y
{
struct x a;
double d;
};
printf("%d",sizeof(union y));

Options :-
a)8
b)5
c)4
d)1

推荐答案

8.

因为,double是的大小8 ,因此联合大小将为 8字节(最大的一个)。

int将占用2或4个字节(取决于编译器),char将占用1个字节,这使得总数为3或5.

工会占用的内存将是大到足以容纳工会中最大的成员。



-KR
8.
Because, double is size of 8, so the union size will be 8 bytes (largest one).
int will occupy 2 or 4 bytes(compiler dependent) and char will 1 bytes, which makes the total of 3 or 5.
The memory occupied by a union will be large enough to hold the largest member of the union.

-KR


不低于8,非常高可能8 ,但机器(和编译器)依赖。
No less than 8, with very high probably 8, however machine (and compiler) dependent.


这篇关于什么是输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆