编译器运行中止(C++)


#include<iostream>
#include<cstring>
#include<string>
using namespace std;

int main()
{
    char hello[20] = "hello world";
    const char* cpp = "hello cpp";
    cout << cpp << endl;
    cout << hello;
    delete hello;
    delete cpp;
    return 0;
}

运行后的反应
img

delete都是不可以的,只有new出来的指针才需要delete,其它都不需要delete

?你是打了断点之后开的debug么
我直接run是能跑出来的

img