标签:string 小端 html struct union cout ios namespace logs
#include <stdio.h> typedef union un{ int i; char ch[2]; } un; int main() { un u; u.ch[0] = 10; u.ch[1] = 1; printf("%d", (short)u.i); return 0; }
#include<iostream> #include <string.h> #include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <memory.h> using namespace std; typedef struct AA { int b1:5; int b2:2; }AA; int main() { AA aa; char cc[100]; strcpy(cc,"0123456789abcdefghijklmnopqrstuvwxyz"); memcpy(&aa,cc,sizeof(AA)); cout << aa.b1 <<endl; cout << aa.b2 <<endl; }
这个题在位域的博客中说过http://www.cnblogs.com/13224ACMer/p/6298764.html
标签:string 小端 html struct union cout ios namespace logs
原文地址:http://www.cnblogs.com/13224ACMer/p/6298765.html