array of structure

//This program doesn't allow me to give all input
struct food
std::string name;
float diameter;
float weight;
int main()
using namespace std;
food *pizza = new food[3];
cout<<"\nEnter detail: ";
cout<<"\nDiameter: ";
cout<<"\nName: ";
getline(cin, pizza->name);
cout<<"\nWeight: ";

cout<<endl<<pizza->name<<" has weight "<<pizza->weight<<" and diameter "<<pizza->diameter;
return 0;
Do not mix stream operators and getline.
If you absolutely need to use getline — use cin.ignore() before that.
Thnx for the help.
Topic archived. No new replies allowed.