1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| #include<iostream> #include<stdio.h>
using namespace std;
struct test1 { char a; int b; char c; };<!--more--> struct test2 { char a; char b; int c; }; union { char a; int b; } test3; int main(void) { test1 a; cout<<sizeof(a)<<endl; test2 b; cout<<sizeof(b)<<endl; test3.b=1; if(test3.a==1) cout<<"小端模式"<<endl; else cout<<"大端模式"<<endl; return 0; }
|