双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

new struct 求大神

q7822819 q7822819 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include "stdafx.h"
#include <iostream>
struct test
{
char name[20];
double num;
};

int _tmain(int argc, _TCHAR* argv[])
{ using namespace std;
test *ps=new test[2];
cin.get(ps[0].name,20);
cin.get();
cin>>ps[0].num;
cin.get();
cin.get(ps[1].name,20);
cin.get();
cin>>ps[1].num;
cin.get();
cout << ps[0].name<<endl;
cout << ps[0].num <<endl;
cout << ps[1].name <<endl;
cout<<ps[1].num <<endl;
delete []ps;
return 0;
}
delete []ps是正确的吧
为什么我用cin.get(ps.name,20);不能用->符还是用.看书看糊涂了
...全文
评论 3
收藏 已收藏
分享
返回顶部
q7822819
新手乐园 33,315 成员 41,769 内容