用new运算符初始化但个数据存储区

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

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

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