变量周围的VS报告堆栈已损坏
VS reporting stack around the variable was corrupted
我的平台是Windows 7 x64。此代码:
#include <iostream>
#include <string>
#include <stdint.h>
#include <sstream>
using namespace std;
int main()
{
string line;
int c = 3;
while(c-- && getline(cin, line))
{
stringstream sstr;
sstr << line;
uint32_t data;
int r = sscanf(sstr.str().c_str(), "%d", &data);
if (r == 1)
{
cout << data << endl;
}
}
return 0;
}
将整数作为输入,打印它们,并正确存在。如果我将data
的类型更改为uint16_t
,那么就在从main((函数返回之前,VS 2010抛出一个错误:
运行时检查失败#2-变量"数据"周围的堆栈已损坏
我想知道为什么VS 2010对uint16_t
如此愤怒?有什么解释吗?
可能是因为%d
引用了一个32位的值。对于16位值,请尝试%hd
。
相关文章:
- gdb错误:Backtrace已停止:上一帧与此帧相同(堆栈已损坏?)
- 变量周围的堆栈'...'已损坏
- 运行时检查失败 #2 变量"A"周围的堆栈已损坏
- 运行时检查失败 #2 - 变量"e"周围的堆栈已损坏。发生
- 运行时检查失败 #2 - 变量周围的堆栈'...'已损坏
- 运行时检查失败 #2 - 变量"l1"周围的堆栈已损坏
- 数组变量周围的堆栈已损坏
- 运行时检查失败 - 变量周围的堆栈已损坏
- 调试:运行时检查失败 #2 - 变量"LoggerThread"周围的堆栈已损坏
- 运行时检查失败 #2 - 变量"数字选择"周围的堆栈已损坏
- 运行时间检查:变量周围的堆栈已损坏
- 变量"name"周围的堆栈已损坏C++
- MS 工作室 17 变量周围的堆栈已损坏
- 错误:运行时检查失败 #2 - 变量周围的堆栈已损坏
- C++指针:数组的堆栈已损坏
- 变量周围的堆栈已损坏
- C++ 变量周围的堆栈已损坏
- 运行时检查失败 #2 - 变量周围的堆栈---已损坏
- VS2010和OpenCV:变量周围的堆栈已损坏
- 指针函数参数已损坏,堆栈已损坏