Let's say the user inputs
Sarah Freshman Computer Science Major
John Sophomore Math Major
I was wondering how am I able to store these multiple inputs into a list?
Name = [Sarah, John]
Year = [Freshman, Sophomore]
Major = [Computer Science Major, Math Major]
I am able to store the first two (Sarah/Freshman & John/Sophomore) into a list, but the latter part is hard because the major is separated into spaces.
--Edit: Example Code--
I am new to C++ and am trying to create a program that asks the user personal questions.
std::vector<std::string> name, year, major;
std::cout << "Hello, what is your Name Year Major? "; //asks user first
std::cin << name;
std::cin << age;
std::cin << major;
int n;
std::cout << "How many students will you input? "; //enter other students info
std::cin << n;
for (int a=0;a<n;a++){
std::cout << "Please enter Name Age Major for student #" << a << ": ";
std::string a, b, c;
std::cin >> a;
std::cin >> b;
std::cin >> c; //this part throws me off
name.push_back(a);
age.push_back(b);
major.push_back(c);
}