动态分配与释放 单个数据的存储区

#include<iostream>
using namespace std;
int main() {

    int *p;
    p = new int;
    if (p == NULL)
    {
        cout << "allocation failure" << endl;
    }
    else
    {
        *p = 15;
        cout << "p 的值为: "<<*p << endl;
        delete p;
    }
    return 0;
}

posted @ 2022-07-05 10:47  江南王小帅  阅读(26)  评论(0)    收藏  举报