#include<iostream>
#include<string>
using namespace std;
struct stud{
int number;
string name;
int score;
};
int main(void)
{stud *p;//开辟动态内存
p=new stud;
cout<<"输入姓名"<<endl;
cin>>p->name;
cout<<"输入学号"<<endl;
cin>>p->number ;
cout<<"输入分数"<<endl;
cin>>p->score ;
cout<<p->name<<endl;
cout<<p->number<<endl<<p->score<<endl;
delete p;//释放动态内存
}
动态分配内存空间
最新推荐文章于 2023-02-05 23:35:43 发布