摘要: #include #include #include struct person {int a;int m;char b;char c;};#define FIND(type, member) (size_t)&(((type *)0)->member)//这里面size_t这样定义的,typedef unsigned int size_t,定义在stddef.h文件中.int main(){int entry1 = FIND(struct person, a); int entry2 =FIND(struct person, b); int entry3=FIND(struct 阅读全文
posted @ 2013-07-24 17:54 songnb_7 阅读(887) 评论(0) 推荐(1) 编辑
摘要: 先看一个结构体:struct S1{ char c; int i;};sizeof(s1)在VC6中按默认设置得到的结果为8。S1 s1 = { 'a', 0xFFFFFFFF };定义上面的变量后,加上断点,运行程序,观察s1所在的内存,你发现了什么以我的VC6.0(sp6)为例,s1的地址为0x0012FF78,其数据内容如下:0012FF78: 61 CC CC CC FF FF FF FF 阅读全文
posted @ 2013-07-24 17:38 songnb_7 阅读(171) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;int main(){ float a = 1.0f; cout << (int)a << endl; cout << (int&)a << endl; cout << boolalpha << ( (int)a == (int&)a ) << endl; // 输出什么? float b = 0.0f; cout << (int)b << endl; cout << 阅读全文
posted @ 2013-07-24 16:06 songnb_7 阅读(358) 评论(0) 推荐(0) 编辑