首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

数据的内存结构有关问题

2012-12-14 
数据的内存结构问题C/C++ code#include stdafx.h#include iostreamusing namespace stdtypedef unsig

数据的内存结构问题

C/C++ code
#include "stdafx.h"#include <iostream>using namespace std;typedef unsigned  char u1;typedef   signed  char i1;typedef unsigned short u2;typedef   signed short i2;typedef unsigned  long u4;typedef   signed  long i4;int _tmain(int argc, _TCHAR* argv[]){    u2 n1 = 11;    u2 n2 = 12;    u2 n3 = n1<<8 | n2;    cout<<n1<<endl;    cout<<n2<<endl;    u1 *p = (u1 *)&n3;    cout<<(int)p[0]<<endl;    cout<<(int)p[1];    getchar();    return 0;}


输出是
11
12
12
11

不知道为什么我放进去的数据和得到的数据不一样
是内存结构的问题吗?

热点排行