previous | start

Convert a C string to a C++ string

The string class takes care of this with its constructors and/or its overloaded operator=

#include <iostream>
#include <string>
#include <cstdlib>

int main()
{
   char cname[] = "Bob";

   string name;

   name = "Bob";

   // or

   name = cname;

}


previous | start