小编kre*_*esh的帖子

您的程序中引发的访问冲突(分段错误)

我正在处理USACO页面上的第一个问题,我收到一条错误消息:

Execution error: Your program had this runtime error:
        Exceeded memory or invalid memory reference. The program ran for
        0.000 CPU seconds before the error. It used 3372 KB of memory. 
Run Code Online (Sandbox Code Playgroud)

我很确定我知道为什么会这样:当我运行我的程序时,它编译并执行正常,但是一旦程序完成,弹出一个框说"main.exe已经停止工作......",然后冻结了.当我运行调试器时,我收到此错误: an access violation (segmentation fault) raised in your program.这是什么意思,我该如何解决?我看到了其他几个这样的线程,但我无法使用其他线程的反馈来修复我的程序.这是我的代码:

/*
ID: krishna24
LANG: C++
PROG: ride
*/
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

string ride(string comet, string group) {
   int cometsum = 1;
   int groupsum = 1;
   for(int i = 0; i < comet.size(); …
Run Code Online (Sandbox Code Playgroud)

c++ exception segmentation-fault

0
推荐指数
1
解决办法
1135
查看次数

标签 统计

c++ ×1

exception ×1

segmentation-fault ×1