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);不能用->符还是用.看书看糊涂了
#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);不能用->符还是用.看书看糊涂了
...全文
相关推荐
C++基于递归和非递归算法求二叉树镜像的方法
主要介绍了C++基于递归和非递归算法求二叉树镜像的方法,针对二叉树遍历结合实例形式分析了递归与非递归算法的实现与使用技巧,需要的朋友可以参考下
求两直线相交的交点C++源代码
求两任意直线(起点和端点)相交交点,不相交返回NULL,在WINXP,BCB6.0下面已经过N次测试
遍历二叉树,求结点总数及叶子总数
遍历二叉树,求结点总数及叶子总数 遍历二叉树,求结点总数及叶子总数
求集合并集
实现数据结构单链表的设计,用设计的顺序表实现求集合的并集。 单向循环链表
PolygonDispose.rar
C#编程调用GPC库对两个多边形点坐标作比较,求相差 、相交 、异或 、合并后的点坐标


新手乐园

