How to convert a char array to a string?

Converting a C++ string to a char array is pretty straightorward using the c_str function of string and then doing strcpy. However, how to do the opposite?

I have a char array like: char arr[ ] = "This is a test"; to be converted back to:
string str = "This is a test.

4 Answers
4

Leave a Comment