码迷,mamicode.com
首页 > 其他好文 > 详细

Run-Time Check Failure #2 - Stack around the variable 'usval' was corrupted

时间:2014-10-27 14:21:13      阅读:295      评论:0      收藏:0      [点我收藏+]

标签:run-time check   failure #2   stack   corrupted   

“val” 为 16进制的字符串,想把字符串每4位的数据提取出来,转成 unsigend short类型,数据已经提取出了,但是在函数调用结束时报错: Run-Time Check Failure #2 - Stack around the variable ‘usval‘ was corrupted。

TCHAR* pMacValue = (TCHAR*)(LPCTSTR)val;
TCHAR mac_item[16] = {0};
unsigned short usval = 0;
for(int t = 0;t<tmp->Size;t++)
{    
_tcsncpy(mac_item, pMacValue+t*4, 4);
_stscanf(mac_item, _T("%X"), &usval);
}

 修改类型后,就不在报错了:

TCHAR* pMacValue = (TCHAR*)(LPCTSTR)val;
TCHAR mac_item[16] = {0};
unsigned long usval = 0;
for(int t = 0;t<tmp->Size;t++)
{    
_tcsncpy(mac_item, pMacValue+t*4, 4);
_stscanf(mac_item, _T("%X"), &usval);
}

希望专家们看到后能帮忙解答下导致问题产生的原因。

Run-Time Check Failure #2 - Stack around the variable 'usval' was corrupted

标签:run-time check   failure #2   stack   corrupted   

原文地址:http://blog.csdn.net/gllg1314/article/details/40506685

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!