Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/158.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 通过删除堆的空间来获取断点_C++ - Fatal编程技术网

C++ 通过删除堆的空间来获取断点

C++ 通过删除堆的空间来获取断点,c++,C++,在此代码中,用户输入具有任意列号的矩阵数组,我检查用户输入的行的矩阵列。如果行的列不匹配,我想删除以前从堆空间获得的空间。当我想删除堆中int**行的空间时,如果列数超过5,这个节目给了我一个转折点,我想知道为什么 在这里输入代码 首先在调试器中运行调试生成,以确定崩溃的位置。然后,当崩溃发生时,查看相关变量的值,例如,如果任何指针为空。如果您仍然无法理解,请更新您的问题以仅显示相关代码,并指出崩溃发生在哪一行以及相关变量的值。另外,请编辑您的问题,以显示如何调用此函数。实际上,我之前的评论是错

在此代码中,用户输入具有任意列号的矩阵数组,我检查用户输入的行的矩阵列。如果行的列不匹配,我想删除以前从堆空间获得的空间。当我想删除堆中int**行的空间时,如果列数超过5,这个节目给了我一个转折点,我想知道为什么

在这里输入代码


首先在调试器中运行调试生成,以确定崩溃的位置。然后,当崩溃发生时,查看相关变量的值,例如,如果任何指针为空。如果您仍然无法理解,请更新您的问题以仅显示相关代码,并指出崩溃发生在哪一行以及相关变量的值。另外,请编辑您的问题,以显示如何调用此函数。实际上,我之前的评论是错误的。。。从停止使用指针开始!使用或。我已经在崩溃的那一行被注释了。请给我一个使用指针的解决方案。我需要它。我假设它在for循环中?那么条件i是条件i
Input(mtx->matrix, &(mtx->matrixDim).column, callinpnum++);/*calling the function Input*/

void Input(int** row, int* columnmat, int callinpnum)
{
char ch = 0;
int colkeep = 0;
int counter1 = 1;
int counter2 = 0;
int counter3 = 0;
static int* guard = nullptr;/*it check the column matching*/
int colcompute = 0;
int* tmp = nullptr;
int* dynamic = nullptr;

int* tmp1 =new int [callinpnum + 1];/*getting new space for the guard to keep the numbers of new rows columns.*/
if(guard)
{
    for(int i = 0;i < (callinpnum);i++)
    {
        tmp1[i] = guard[i];
    }
    delete guard;
    guard = nullptr;
}
guard = tmp1;/*guard save the number number of the columns of each row.*/

cout << "Enter the elements of the row " << callinpnum + 1 << endl;
while (ch != ';')
{
    counter2++;
    if (counter2 % 5 == 1)/*getting new space for the user to enter the new arrays(columns).*/
    {
        tmp = new int[counter1 * 5];
        if (dynamic)
        {
            for (int i = 0; i < (counter1 - 1) * 5; i++)
            {
                tmp[i] = dynamic[i];
            }
            delete dynamic;
            dynamic = nullptr;
        }
        counter1++;
        dynamic = tmp;
        row[callinpnum] = (dynamic);
    }
    //colkeep = (counter2 - 1);

    for (; colkeep < counter1 * 5 && ch != ';'; colkeep++)
    {
        row[callinpnum][colkeep] = 0;
        cin >> ch;
        if (ch == ',' || ch == ';')
        {
            colcompute++;
        }
        while (ch != ',' && ch != ';')
        {
            row[callinpnum][colkeep] = (row[callinpnum][colkeep] * 10) + (ch - 48);
            cin >> ch;
            if (ch == ',' || ch == ';')
            {
                colcompute++;
            }
        }
    }
    counter2 = colkeep;
}
guard[callinpnum] = colcompute;
if(callinpnum > 0)/*checking.*/
{
    for(int i = 0;i < callinpnum;i++)
    {
        if(guard[i] != guard[i+1])
        {
            cout<<"Your matrix columns doesn't match together\n";
            (int i = 0; i <= callinpnum; i++)
            {
                delete row[i];/*if the column number be over 5 break from the program.*/
                row[i] = nullptr;
            }

            return;
        }
    }
}