我在程序中遇到堆栈溢出异常C++
I'm getting a stack overflow exception in C++ program
我得到了一个system.stackoverflowexception。
我认为它发生在insert()
函数内部的某个地方。
void insert(char* word){
int r1 = rand()%x; // Here is where I suspect the problem starts
int c1 = rand()%x;
if(gameBoard[r1][c1]=="") {
gameBoard[r1][c1] = word;
insertWordCopy(word);
} else
insert(word);
}
以下内容不正确,因为它比较了指针:
if(gameBoard[r2][c2]=="") {
因此,代码几乎肯定总是沿着else
分支向下,从而导致无限递归。
相关文章:
- 对象接收堆栈溢出异常 c++ 的排序向量
- 主函数执行时C++堆栈溢出异常
- 如何在编译器方便的情况下在 C/C++ 中发布算术溢出异常
- 奇怪的消息 (_Base_bitset::_M_do_to_ulong) 从溢出异常处理程序中打印出来
- C 堆栈溢出异常,可能是由于递归引起的
- std::list 和 std::vector 中的堆栈溢出异常
- c++ 的除法的其余部分出现"堆栈溢出"异常
- 我在程序中遇到堆栈溢出异常C++
- 堆栈溢出异常中c++和c#之间的差异
- 愚蠢程序中的堆栈溢出异常
- 缓冲区溢出异常(按fscanf_s)
- 输入 main() 之前出现堆栈溢出异常
- 如何获取有关混合应用程序中缓冲区溢出异常的信息
- 为什么在此方法中添加cout行可以阻止我的程序在Windows中触发缓冲区溢出异常?
- 如何调试堆栈溢出异常
- 为什么我的大5D数组只作为成员变量导致堆栈溢出异常?
- main()之前的堆栈溢出异常
- 如何创建无限递归,这将抛出堆栈溢出异常
- 大型数据集的堆栈溢出异常
- c++中栈溢出和分段错误的危险