stucture array

Could someone please give me an example of how to use


cin >>


to input data into a simple structure array..

Last edited on
Do you mean an array of structures or a structure with an array inside?
Here is somewhat of an example..

CIN is used here to input data into the Pizza info[1] array..


How could I use CIN to input data into an Array of Structures.. I hope that makes sense.. Thanks


#include <iostream>
using namespace std;

struct Pizza
{
char name[20];
float diameter;
int weight;
};

int main()
{



Pizza info[1];




cout << "Enter a pizza company \n\n\n\n\n";
cin.getline(info[0].name, 20);


cout << "Enter diameter \n\n";
cin >> info[0].diameter;

cout << "Enter weight \n\n";
cin >> info[0].weight;

cout << info[0].name << "\n\n";
cout << info[0].diameter << "\n\n";
cout << info[0].weight << "\n\n";


return 0;


}

Last edited on
Topic archived. No new replies allowed.