I'm probably an idiot, I know. This is probably a duplicate, but for the life of me I couldn't find an answer after looking for over an hour. I guess I don't know how to phrase a search. All I want is to be able to print out a string from a function based on user input. This isn't part of the program I'm building right now, but it illustrates my problem.
#include "../std_lib_facilities.h"
string make_name()
{
string name;
int selection;
cout << "Enter 1 steve. Enter 2 Mike.\n\n";
cin >> selection;
if (selection == '1')
name = "Steve";
else if (selection == '2')
name = "Mike";
return name;
}
int main()
{
cout << "Make a name\n";
make_name();
cout << "Your name is " << make_name;
keep_window_open();
}
Instead of printing Mike or Steve, it prints nonsense. I've been working on all the other parts of my program, but now this is the only problem I have. So, lay into me. What am I doing wrong?