小编Bor*_*ris的帖子

我应该如何在这个场合使用删除c ++

所以这是我的代码:

#include "stdafx.h"
#include <iostream>

using namespace std;

#define MAX 5
#define STR_LENGTH 40

void main()
{
    char *p_str[MAX];

    for (int i = 0; i < MAX; i++)
    {
        *(p_str+i) = new char(STR_LENGTH);
        cout << "Please enter a string:  ";
        cin >> *(p_str+i);
    }

    for (int i = 0; i < MAX; i++)
    {
        cout << *(p_str+i) << endl;
        delete (p_str+i);
    }

}
Run Code Online (Sandbox Code Playgroud)

在那里的最后一行,我有删除,但它到达那里时,它有什么想法解决它吗?

c++ delete-operator

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

标签 统计

c++ ×1

delete-operator ×1