编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习8

#include <iostream>
using namespace std;
const int Size=20;
struct Pizza
{
 char company[Size];
 double diameter;
 double weight;
};
int main()
{
 Pizza *piz=new Pizza;//使用new创建动态结构
 cout<<"What's the diameter of pizza: ";
 cin>>piz->diameter;
 cin.get();//读取下一个字符
 cout<<"What's the name of pizza company: ";
 cin.get(piz->company,Size);
 //cin.get();
 cout<<"What's the weight of pizza: ";
 cin>>piz->weight;
 cout<<"diameter: "<<piz->diameter<<endl;
 cout<<"company: "<<piz->company<<endl;
 cout<<"weight: "<<piz->weight<<endl;
 system("pause");
 return 0;
}