Say I want to quickly store 3 personality traits of 3 different people into an array quickly, then display them in a format such as:
Johny:
Favorite pizza: Pepperoni
Favorite animal: Dog
Favorite Color: Blue |
(so four inputs/person)
But I don't want to enter 3 names, then 3 favorite pizzas, then 3 favorite animals.
I want to input all 4 variables per single person at once...
so when collecting the data, the user will be asked for name, then pizza, then animal, then color.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
void inputs(int);
string name[3];
int one;
int main()
{
for (one=0;one<=2;one++)
{
inputs(one);
}
for (one=0;one<=2;one++)
{
cout << name[one] << endl;
}
return 0;
}
void inputs(int i)
{
cout << "Enter person(" << i + 1 << ") name" << endl;
cin >> name[one];
}
|
This is what I have but I don't know how I would interrupt the name array to allow for the other 3 array inputs... help??
I believe I should use a different method rather than "for" statement to call attention to getting the input.. but I can't figure out how..
EDIT: again the point is to be able to store and output all data as an array