Structure/Array issues with index call

closed account (ow5zhbRD)
I am working on an assignment that requires the storing of employee information in a structure, and then an array. If the array is declared without set values, how do I assign user input information to an address as it's entered, and pull up a specific employee afterward?

struct CustomerAccounts
{
string CustomerName
string CustomerAddress
string City
string State
int ZipCode
int Telephone
double Accountbalance
double lastpayment
};


int main()

{
const int NUM_WORKERS = 20;
CustomerAccounts array[NUM_WORKERS];
int index;
int userchoice;
int CustomerNumber;

//Main Menu
cout << "1. Enter new account information" ;
cout << "2. Change account information" ;
cout << "3. Display all account information" ;
cout << "4. Exit the program:" ;
cin >> userchoice;

if( userchoice = "1")

{
for (index = 0; index < NUM_WORKERS; index++)

cout << "Enter Customer Name";
cin >> CustomerAccounts.CustomerName;

cout << "Enter Customer Address";
cin >> CustomerAccounts.CustomerAddress;

cout << "Enter Customer City:";
cin >> CustomerAccounts.City;

cout << "Enter Customer State:";
cin >> CustomerAccounts.State;

cout << "Enter Customer Zip Code:";
cin >> CustomerAccounts.ZipCode;

cout << "Enter Customer Telephone Number:";
cin >> CustomerAccounts.Telephone;

cout << "Enter Customer Account Balance:";
cin >> CustomerAccounts.Accountbalance;

cout << "Enter Date of Last Payment:";
cin >> CustomerAccounts.lastpayment;

cout << "You have entered information for customer number" << (index);
}
An array of your structure is accessed in the same way you would access an array of int:
1
2
3
4
5
6
7
int int_array[10];

int_array[0] = 100;

CustomerAccounts accounts[10];

accounts[0].CustomerName = "Some Great Customer";
Topic archived. No new replies allowed.