cygwin_exception::open_stackdumpfile:将堆栈跟踪转储到 class4.exe.sta
cygwin_exception::open_stackdumpfile: Dumping stack trace to class4.exe.stackdump
main.cpp
#include <iostream>
#include <vector>
#include <cstdlib>
#include <chrono>
using namespace std;
int randNum = 0;
int digit = 0;
int length = 0;
int choice = 0;
int remainder = 0;
int counter = 0;
int origArray[5] = { };
int reverseArray[5] = { };
int temporary = 0;
int index = 0;
bool repetition = true;
int main () {
srand(std::chrono::duration_cast<std::chrono::milliseconds>
(std::chrono::system_clock::now().time_since_epoch()).count()%2000000000);
// needed to autograde some test cases in Mimir
do {
cout << "Enter number of digits in code (3, 4 or 5): ";
cin >> choice;
cout << endl;
} while ((choice != 0) && (choice != 3) && (choice !=4) && (choice !=5));
switch (choice) {
case 0: {
cout << "Enter code: ";
cin >> digit;
cout << endl;
while (digit > 0) {
remainder = digit % 10;
digit = digit / 10;
origArray[counter] = remainder;
counter++;
}// while loop that separates digits in reverse
cout << "Enter number of digits in code: " << endl;
cin >> length;
for (int i = 0; i < length; i++) {
reverseArray[i] = origArray[length - i - 1];
}// for loop that sets the digits in the right order
cout << "Number to guess: ";
for (int i = 0; i < length; i++) {
cout << reverseArray[i];
if (i < length-1)
cout <<"-";
}// for loop that outputs the digits with a dash
}// what runs when 0 is selected
break;
default: {
while(temporary < choice) {
repetition = false;
randNum = rand() % 10;
for (int i = 0; i < choice; i++) {
if (randNum == reverseArray[i])
repetition = true;
}// for loop that sees if random number is equal to inputted
digit value array
if (repetition == false) {
reverseArray[index] = randNum;
index = index + 1;
repetition = repetition + 1;
}// for loop that populates array with random digits
}// while loop that goes through each index of array.
cout << "Number to guess: ";
for (int i = 0; i < choice; i++) {
cout << reverseArray[i];
if (i < choice-1)
cout <<"-";
}//for loop that outputs the digits with a dash
break;
}// what happens when 3, 4, or 5 are selected
}//switch statement
}
每当我运行默认情况时,我都会收到"cygwin_exception::open_stackdumpfile:将堆栈跟踪转储到 class4.exe.stackdump"。我正在日食中运行它。
这种情况时不时地发生,但我不知道为什么它只是偶尔发生。
我将不胜感激任何帮助,因为我在网上找不到有用的信息。
谢谢
在
reverseArray[index] = randNum;
index = index + 1;
repetition = repetition + 1;
这可以通过范围检查条件来防止
if(0 <= index && index < 5){
reverseArray[index] = randNum;
index = index + 1;
repetition = repetition + 1;
}
我不确定这种情况是否会改变您的代码逻辑, 然后,如果您输入 0,它会给出一个数字序列 但是对于 3 或 4 或 5,它给出了一个巨大的循环,几乎就像无限循环一样
相关文章:
- 分段故障(堆芯转储)矢量
- Cppcheck生成xml转储文件
- 如何找出GDB的SIGTRAP核心转储的根本原因
- C++映射分割错误(核心转储)
- 在c++中初始化矩阵时出现分段错误(核心转储)
- 在c++中键入向量中的所有值后,得到分段错误(核心转储)
- 浮点异常(核心转储)#694457
- 分段错误(核心转储)但无法弄清楚
- 链接到libkcapi时没有核心转储
- 检测到堆栈粉碎:已终止 中止(核心已转储)
- 正在处理故障(堆芯转储)
- 分段错误(核心转储) - 使用 SavedModel 的 Tensorflow C++ API 进行推断
- 我不知道为什么这段代码会让核心被转储?
- C++运行时错误与快速排序算法抛出堆栈转储错误
- 在基数排序中,我得到 munmap_chunk():无效指针和中止(核心转储).为什么?
- C++指针无法在函数外部传递值和分段错误(核心转储)错误
- cygwin_exception::open_stackdumpfile:将堆栈跟踪转储到 class4.exe.sta
- C++快速将 int 数组内容转储到文本文件中
- 合并排序:分段错误核心转储
- WinDbg 不显示某些小型转储文件的完整堆栈跟踪