03 2013 档案

摘要:Most of time, we will write some common code for MFC and Win32 applications, such as convert operations(char, string, CString, int... convertion). So the code should support MFC and Win32 features. In this article, I will give you an example about how to use MFC features in Win32 application. First. 阅读全文
posted @ 2013-03-27 10:54 nchxmoon 阅读(305) 评论(0) 推荐(0) 编辑
摘要:题目要求:编写一个程序,无论是对于允许嵌套注释,还是不允许嵌套注释的程序,都能正常运行,但是产生的结果不一样。提示:在/**/之间,双引号“是注释的一部分;在双引号”“之间,/**/又是字符串。以下参考答案摘录自《C陷阱与缺陷》:对于/*/**/"*/"/*"/**/,支持嵌套返回 ”*/“(去除前后的两个注释),不支持返回 ”/*“(根据最近匹配原则);对于/*/*/0*/**/1,支持嵌套返回 1(去掉前面的两个注释),不支持返回 0*1,即0(去掉前后的两个注释)。 阅读全文
posted @ 2013-03-22 16:57 nchxmoon 阅读(477) 评论(0) 推荐(0) 编辑
摘要:/*** 获取制定范围的随机数.** 数据范围:uiStart~uiEnd (uiStart > uiEnd),随机数包括uiStart, uiEnd的取值.*/ 1 // GetRand from uiStart to uiEnd. 2 typedef unsigned int UINT; 3 UINT GetRand(UINT uiStart, UINT uiEnd) 4 { 5 if(uiStart > uiEnd) 6 { 7 cout<<"uiStart have to less than uiEnd."<<endl; 8 re 阅读全文
posted @ 2013-03-21 17:07 nchxmoon 阅读(220) 评论(0) 推荐(0) 编辑
摘要:1 // Swap 2 void Swap(int* a, int* b) 3 { 4 int tmp = *a; 5 *a = *b; 6 *b = tmp; 7 } 8 9 // GCD: Greatest Common Divisor10 int GCD(int i, int j)11 {12 if(i < 0 || j < 0)13 return 0;14 15 if(i < j)16 Swap(&i, &j); // Make sure i > j.17 18 if(j == 0) return i;19 20 ... 阅读全文
posted @ 2013-03-21 15:45 nchxmoon 阅读(312) 评论(0) 推荐(0) 编辑
摘要:1. 打开反汇编窗口:调试模式下,按Ctrl+F11。2. 术语: 2.1 ESP(Extended Stack Pointer): 堆栈指针,寄存器存放当前线程的栈顶指针; i.e: move ebp, esp -- 用ebp保存当前栈指针; 2.2 EBP(Extended Base Pointer): 基址指针,寄存器存放当前线程的栈底指针; i.e: push ebp -- 将基址指针压入栈; 2.3 EIP:寄存器存放下一个CPU指令存放的内存地址,当CPU执行完成当前的指令后,从EIP寄存器中读取下一条指令的内存地址,然后继续执行; 2.4 EAX:累加器(Accumu... 阅读全文
posted @ 2013-03-20 15:16 nchxmoon 阅读(8891) 评论(0) 推荐(0) 编辑