previous | start

## Pointers to Character Strings

- The `string` class has a constructor `string(char *)` that you can use to convert any character pointer or array to a safe an convenient `string` object.

  >     char* p = "Harry";
  >     string name(p);

- Use the `c_str` member function of the `string` class to obtain a `char*` pointer that points to the first character in the `string` object.
- The `tempnam` function in the standard library yields the name of a temporary file, and expects a `char*` parameter for the directory name.

  >     string dir = . . .;
  >     char* p = tempnam(dir.c_str(), NULL);
  >     string file_name(p);

previous | start