I am having quite a bit of trouble just getting user input/ or even storing strings, etc. so let me lay out my problem.
Personal Project, so no limits, I do like to know how stuff works though.
Array or Vector
C_Strings, Strings, Char Array;
I understand those are what I have to work with.
I want to make a list of choices for the user, and store them so that I can easily print them out by calling their number.
Also the user will only enter in a number, then the number will correspond to the choice, so therefore I only really need to output all of the options in a timely manner.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include <iostream>
#include <vector>
#include <string>
vector<string> user_choices;
void initializeChoices(vector<string>& user_choices);
using namespace std;
int main(){
initializeChoices(user_choices);
cout << "Hello, which number would you like to pick?" << endl;
for (int i = 0; i < 1; i++){
cout << i << ": " << user_choices[i] << endl;
}
return 0;
}
void initializeChoices(vector<string>& user_choices){
user_choices.push_back("Choice 1");
}
|
My code so far. I know it is wrong, the compiler went crazy with errors.