C++运行出现"what(): std::bad_alloc"的解决办法

注:这里只是我的代码出现这种情况及对应的解决办法,你的代码不一定出现和我一样的情况。左移这篇随笔仅供参考。

运行程序出现如下结果:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Process returned 3 (0x3)   execution time : 5.837 s
Press any key to continue.

然后发现是 for 循环里面的,本应写成

for (int j = 1; j <= 3; j ++)

的地方,写成了

for (int j = 1; j <= 3; j --)

改过来就好了。

posted @ 2019-06-01 11:17  zifeiy  阅读(6123)  评论(0编辑  收藏  举报