C++ std::cout分段错误

C++ std::cout分段错误,c++,segmentation-fault,cout,C++,Segmentation Fault,Cout,是否有任何原因表明过度使用cout会导致分段错误 一段代码遍历一个矩阵,然后可能再次递归遍历矩阵的各个部分,其中包含以下行: matrix matrix::topLevelFunction( void ) { for (int i=1; i<NRows-1; i++) { cout << "\rRow = " << i+1 << " / " << NRows << " " <

是否有任何原因表明过度使用
cout
会导致分段错误

一段代码遍历一个矩阵,然后可能再次递归遍历矩阵的各个部分,其中包含以下行:

matrix matrix::topLevelFunction( void )
{
     for (int i=1; i<NRows-1; i++)
     {
             cout << "\rRow = " << i+1 << " / " << NRows << "    " << flush;
             for (int j=1; j<NCols-1; j++)
             {
                 recursiveFunction(i, j)
             }
      }
}

void matrix::recursiveFunction(int i, int j)
{
    double min;
    if (i == 0 || j == 0 || i == NRows-1 || j == NCols-1)
    { }
    else
    {
        min = data[i][j] + 10;
        for (int row = -1; row <= 1; ++ row)
        {
            for (int col = -1; col <= 1; ++ col)
            {
                if (row != 0 && col != 0 && data[i+row][j+row] < min)
                    min = data[i+row][j+col];
            }
        }
        if (data[i][j] <= min)
        {
            data[i][j] = min + 0.0001;
            for (int row = -1; row <= 1; ++ row)
            {
                for (int col = -1; col <= 1; ++ col)
                {
                    if (row != 0 && col != 0)
                        recursiveFunction(i + row, j + col);
                }
            }
        }

    }
}
矩阵矩阵::topLevelFunction(void)
{

对于(int i=1;我能给我们看一下递归函数吗?
?你通过调试器运行了吗?它应该突出显示它的错误位置。代码看起来不错,
flush
在这里是不寻常的,通常我希望看到一个
endl
-它应该会处理一些事情…我不确定,但这不是一个问题:
如果(row!=0&&col!=0&&data[i+row][j+row]
?如果(row!=0&&col!=0&&data[i+row][j+col],它可能应该是: