Hi. I don't have much experience with this, and I am having trouble getting this function to work. It's purpose is to print a question and ask for a response.
e.g. for request("what is your name?",string name)
i'd like it to store the user's response in string name.
The compiler is telling me: "cannot convert 'std::string' to 'std::string*' for argument '1' to 'void request(std::string*, std::string)'|" Please help me fix it.
Yes, guestgulkan, you're right. I posted the wrong error message. The error should be: "cannot convert 'std::string' to 'std::string*' for argument '2' to 'void request(std::string, std::string*)'|"
rocketboy9000, sorry, I am afraid I don't fully understand. Is the function itself ok?
For example, I'd like the following program to ask for the users name, then print it:
1 2 3 4 5 6 7 8 9
string name;
void request(string question, string* input){
cout<<question;
getline(cin,input,'\n');
}
request("what is your name?", name);
cout<< name;
Should I use the & operator somewhere to fix this?