关于vs2008中“烫烫烫...”或“屯屯屯...“的问题
来源:互联网 发布:c语言编程图形 编辑:程序博客网 时间:2024/05/09 21:33
联系方式:uestc001@gmail.com,欢迎转载,请注明出处http://blog.csdn.net/uestc001/article/details/8454760
今天写代码,出现了“屯屯屯屯”,说明我忘记初始化了。这个屯屯屯很好玩,开始编程那会儿经常遇到,菜鸟,所以很眼熟。
在vs2008里可能遇到“烫烫烫烫烫烫烫烫烫烫烫”或“屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯”。什么意思呢?
请看代码:
- #include "stdafx.h"
- #include <string.h>
- int _tmain(int argc, _TCHAR* argv[])
- {
- unsigned char testArray[256];
- printf("%s\n", testArray);
- unsigned char *p = new unsigned char[256];
- printf("%s\n", p);
- delete []p;
- p = NULL;
- return 0;
- }
#include "stdafx.h"#include <string.h>int _tmain(int argc, _TCHAR* argv[]){ unsigned char testArray[256]; printf("%s\n", testArray); unsigned char *p = new unsigned char[256]; printf("%s\n", p); delete []p; p = NULL; return 0;}
效果:
"烫"的编码是0xCCCC, "屯"的编码是0xCDCD
网上搜了一下,是这么解释的:
debug模式为了便于在出现问题的时候查找原因,编译器会对未手工初始化的数据填充特定的值。
在dbgheap.c中106-109行(VS2008)有如下代码段:
- static unsigned char _bNoMansLandFill = 0xFD; /* fill no-man's land with this */
- static unsigned char _bAlignLandFill = 0xED; /* fill no-man's land for aligned routines */
- static unsigned char _bDeadLandFill = 0xDD; /* fill free objects with this */
- static unsigned char _bCleanLandFill = 0xCD; /* fill new objects with this */
- static _CrtMemBlockHeader * _pFirstBlock;
- static _CrtMemBlockHeader * _pLastBlock;
static unsigned char _bNoMansLandFill = 0xFD; /* fill no-man's land with this */static unsigned char _bAlignLandFill = 0xED; /* fill no-man's land for aligned routines */static unsigned char _bDeadLandFill = 0xDD; /* fill free objects with this */static unsigned char _bCleanLandFill = 0xCD; /* fill new objects with this */static _CrtMemBlockHeader * _pFirstBlock;static _CrtMemBlockHeader * _pLastBlock;
说明:
_bNoMansLandFill,byte No Mans Land Fill, "no-man's-land"的意思是:所有权争执未定的土地,这里表示边界内存。注释说了用这个值填充内存分配的边界。当你访问到这个值的时候,就说明访问越界了。
_bAlignLandFill,byte Align Land Fill, 内存对齐填充值。
_bDeadLandFill,byte Dead Land Fill,填充已经释放的内存空间,比如delete了一段内存空间,这段空间就填充0xDD,再次尝试delete的时候,就会crash了。
_bCleanLandFill,byte Clean Land Fill,堆区未手动初始化的填充值。
0xCC(244)是自动变量为初始化的填充值,栈区分配的时候就填充0xCC。
Vs2008的Debug用0xCD(255)填充堆,两个0xCD和在一起就是“屯”。
总结:出现“烫”或“屯”,解决办法:扩大数组范围或初始化数组 。
参考:http://hi.baidu.com/luosiyong/item/2020760be3629a823c42e208
(完)
此文章来自于【http://blog.csdn.net/uestc001/article/details/8454760】
- 关于vs2008中“烫烫烫...”或“屯屯屯...“的问题
- 关于.netframework 安装不上,或vs2008安装不上的问题
- 关于VS2008或VS2005中app.config数据库配置字符串的三种取法
- 关于vs2008的sort排序的问题?
- 关于 vs2008 与 vs2005 的冲突问题
- 关于VS2008的一些配置问题
- 关于VS2008的破解和卸载问题
- 关于Vs2008 工具箱的修复问题
- 关于VS2008编译器的设置问题。
- 关于VS2008安装的三个问题
- 关于VS2008+opencv2安装调试的问题
- 关于Matlab找不到vs2008或vs2005编译器的解决办法
- 关于Matlab找不到vs2008或vs2005编译器的解决办法
- 关于在 Service 或 BroadcastReceiver 中 startActivity 的问题
- 关于vs2008中,往dataset添加用了临时表的存储过程的问题。
- 关于VS2008问题!
- VS2008中关于“加载安装组件时遇到问题。取消安装”的解决
- VS2008中关于“加载安装组件时遇到问题。取消安装”的解决
- Cookie 安全测试
- tcp push标志
- 腾讯视频怎么下载_QQ视频如何下载到本地保存
- 使用Content Provider
- UNIX文件系统
- 关于vs2008中“烫烫烫...”或“屯屯屯...“的问题
- 2013,你准备好了吗
- 最终一致性
- 【并查集买一送一】Poj 2524——Ubiquitous Religions
- 一个父亲和儿子的故事 并查集相关内容
- openssl windows成功安装步骤
- shell 判断文件是否存在
- What is the difference between LWP and threads?
- web pdf操作