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
and strncpy

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