new struct 求大神
#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);不能用->符还是用.看书看糊涂了