I want to code a generic,reusable function named getname that will prompt the user to enter a name and store the full name in one variable
#include #include using namespace std;
string getname(string quest)
{
cout << quest;
char ans[256];
cin.getline (ans, 256);
return string(ans);
}
int main()
{
string a = getname("enter name: " );
cout << a << endl;
return 0;
}