An array of names in parallel array.

I want to accept keyboard input to a parallel array, one price, one item. I'm not understanding how to create an array of 50 names. I understand reading a string into an array of type char, but that's only good for the first character string. What I'm wanting to do is have a user input a list of items and prices. Is this close?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const ARRAY_SIZE = 31;

double price[ARRAY_SIZE];
string item[ARRAY_SIZE]; 

// user input 
cout << " Enter a price: " << endl;
cin.getline(price, 31);


cout << " Enter the item: " << endl;
cin.getline(item, 31);
 

Is there a need to validate, clear, or restore stream when getline is used? Can getline be used with strings? Our textbook doesn't have an example, and not much info about getline.
At the end of this little assignment, I'll want to output the items and their prices, and total the prices.
Topic archived. No new replies allowed.