// practice4-8.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
const int len = 70;
struct pizza
{
char brand[len];
double diameter;
double weight;
};
int _tmain(int argc, _TCHAR* argv[])
{
using namespace std;
pizza * ps = new pizza;
cout<<"Enter pizza brand:";
cin.getline(ps->brand,len);
cout<<"Enter its diameter;";
cin>>(*ps).diameter;
cout<<"Enter its weight:";
cin>>ps->weight;
cout<<"****************************************"<<endl;
cout<<ps->brand<<"\n"<<ps->diameter<<"\n"<<ps->weight<<endl;
delete ps;
system("pause");
return 0;
}
使用new为结构分配内存而不是声明一个结构变量
最新推荐文章于 2024-07-22 20:08:56 发布