struct pizza
{
char band[20];
int weight;
int radius;
};
int main()
{
pizza exp = new pizza;
cout << "radius: ";
cin >> exp->radius;
* cin.get();**
cout << "bands: ";
cin.get(exp->band,20);
cout << "weight: ";
cin >> exp->weight;
cout << exp->band << " " << exp->weight << " " << exp->radius <<endl;
delete exp;
return 0;
}
為什麼要加cin.get()才行
cin.get()吃掉你輸入的回車,否則下面就讀取不到正確的數據