76 337
Assignments Done
Successfully Done
In May 2019

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions