64 506
Assignments Done
99,1%
Successfully Done
In September 2018

Answer to Question #2158 in C++ for glenn

Question #2158
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
Expert's answer
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions