strcpy_s

Hi I have the following code in an existing project:

CString cString = "blah blah";

char *pBuffer = new char[bufLen];

int bufLen = cString.GetLength()+1;

memset(pBuffer, 0, bufLen);

strcpy_s(pBuffer, bufLen, cString);

This is all ok, but I have to replace the CString with std::string.
Now with the exact same code above (only using std::string cSting), the function strcpy_s gives me the error:

"No instance of overloaded function strcpy_s matches the argument list" and also:

"Too many arguments in function call"

How can I fix this??
Don't use strcpy_s, it's non-standard.
The standard function are
strcpy http://www.cplusplus.com/reference/clibrary/cstring/strcpy/
and strncpy http://www.cplusplus.com/reference/clibrary/cstring/strncpy/

To get a C-style string from a C++ string you can use the methods
c_str http://www.cplusplus.com/reference/string/string/c_str/
or data http://www.cplusplus.com/reference/string/string/data/
The difference in that c_str ensures that the result is '\0' terminated
Topic archived. No new replies allowed.