#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;
}
转载于:https://www.cnblogs.com/lynnycy/p/3433789.html