结构大小

juzixiangchang 2011-03-27 02:35:19
struct stu{
unsigned first:3;
unsigned pad:2;
};
VC下是4,不明白,另外对这种:num的格式也不理解
...全文
102 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hhsuc 2011-04-22
  • 打赏
  • 举报
回复
http://blog.csdn.net/jszj/archive/2009/02/20/3915328.aspx
仔细看一下这个吧
lisong871121 2011-04-22
  • 打赏
  • 举报
回复
vc默认4字节对齐
maoxing63570 2011-03-27
  • 打赏
  • 举报
回复
The mode bit-field has two bits, modified only one, and the other members each have three bits.
maoxing63570 2011-03-27
  • 打赏
  • 举报
回复

A bit-field must be an integral data type. It can be either signed or unsigned . We indicate that a
member is a bit-field by following the member name with a colon and a constant expression
specifying the number of bits:
typedef unsigned int Bit;
class File {
Bit mode: 2;
Bit modified: 1;
Bit prot_owner: 3;
Bit prot_group: 3;
Bit prot_world: 3;
// ...
};
sea_spray 2011-03-27
  • 打赏
  • 举报
回复
大家都支持1楼说的办法呢~~~~
宁谧青风 2011-03-27
  • 打赏
  • 举报
回复
林锐的《高质量程序设计指南》里面 讲得很清楚,建议lz 去看看
菜菜鸟yi 2011-03-27
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 thefirstz 的回复:]
看看位域和内存对齐的相关知识,网上多的是
[/Quote]
同意
枫继续吹 2011-03-27
  • 打赏
  • 举报
回复
按楼上说的去做
昵称很不好取 2011-03-27
  • 打赏
  • 举报
回复
看看位域和内存对齐的相关知识,网上多的是

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧