#include<iostream>
#include <string>
using namespace std;
struct inflatable
{
// std::string name;VC6.0 不能对结构体的string进行初始化 在VC2010或者 uinx C++就可以
// 会报错 error C2552: 'hat' : non-aggregates cannot be initialized with initializer list
char name[20];
double volume;
double price;
};
int main()
{
inflatable hat[3]=
{
{"hat",1.52,80.55},
{"book",1.88,15.2},
};
cout<<hat[0].name<<"\t"<<hat[0].volume<<"\t"<<hat[0].price<<endl;
cout<<hat[1].name<<"\t"<<hat[1].volume<<"\t"<<hat[1].price<<endl;
strcpy(hat[3].name,hat[0].name);
hat[3].price=hat[0].price;
hat[3].volume=hat[0].volume;
cout<<hat[3].name<<"\t"<<hat[3].volume<<"\t"<<hat[3].price<<endl;
return 0;
}
运行都有输出但是最后会崩溃 debug到这里会错