C/C++??????????
???????????? ???????[ 2014/3/19 11:05:41 ] ????????C++ ?? ????
????1.???????
???????磺struct TEST
????{
????char a;
????int b;
????char c;
????}
???????????sizeof??ó?????? 12?? ????????????4byte?? ????a???1byte?????3???????????????b???????a??????4byte?? ????c????????????????? ?????4byte????sizeof??12??
#include "stdafx.h"
#include <iostream>
using namespace std;
struct TEST1 //12
{
char a;
int b;
char c;
};
struct TEST2 //8
{
char a;
char b;
int c;
};
struct TEST3 //8
{
char a;
char b;
char c;
int d;
};
struct TEST4 //12
{
char a[5];
int b;
};
struct TEST5 //8 + 8 + 8 = 24
{
double a; //8
char b; //4
int c; //4??location the b memery
char d[5]; //5
};
int _tmain(int argc?? _TCHAR* argv[])
{
struct TEST1 t1;
struct TEST2 t2;
struct TEST3 t3;
struct TEST4 t4;
struct TEST5 t5;
cout << sizeof(t1) << endl << sizeof(t2) << endl;
cout << sizeof(t3) << endl << sizeof(t4) << endl << sizeof(t5) << endl;
return 0;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11