I am new to C++ so excuse my mistakes; I am trying to create a program that asks the user to input how many siblings do they have, and based on their input, they write down the sibling's Name Age Gender (separated by a space).
std::string name, age, gender;
int n;
std::vector<str::string> siblings;
std::cout << "How many siblings do you have? ";
std::cin >> n;
for (int a=0;a<n;a++){
std::string x;
std::cout << "Please enter info for sibling #" << (a+1) << ": ";
std::cin >> name;
std::cin >> age;
std::cin >> gender;
x += " " + name;
x += " " + age;
x += " " + gender;
siblings.emplace_back(x)
}
Let's say that the user inputted "3" siblings with the information:
Michael 14 Male
Sam 20 Female
Anna 8 Female
How do I get access to the first sibling's age, second sibling's age, third sibling's age? Same with name? Gender?
I tried doing
std::cout << age
But that only gives me one result.