hyetpang
2016-04-27 01:47关于c++结构体长度的问题
#include <iostream>
using namespace std;
struct Student{
char ch;
int i;
}st1;
struct name{
}n;
struct j{
static int i ;
}l;
struct nam{
static int i;
}e;
struct Studen{
}st;
int main(){
int s = sizeof(st1);
int n2 = sizeof(n);
int l = sizeof(l);
int e1 = sizeof(e);
int se = sizeof(st);
printf("%d %d %d %d %d", s, l, n2, e1, se);
return 0;
}
在这个程序中,第二个输出的数字为什么是4呢?不应该是1么?
- 点赞
- 回答
- 收藏
- 复制链接分享
5条回答
为你推荐
- 求助 C语言(结构体 函数) 查找书籍
- c语言
- c++
- 开发语言
- 2个回答
- c++string和char[],我有一段代码,和测试数据,但是我发现使用string时这段代码出错了,我把string换成对应的char []后代码正常运行
- c++
- 4个回答
- c++基础问题,关于定义数组。
- 数组
- c/c++
- c++
- 0个回答
- python3使用ctypes有些c类型没有怎么办?
- dll
- python
- ctypes
- 1个回答
- 关于指针强制转换的一点疑问…………
- windows
- c
- c++
- 指针
- 1个回答
换一换