I have a VS 2010 C++ solution with two projects, one generates a DLL and the other is the driver to the DLL functions. All the following code
char cstring [256];
strcpy (cstring, "C String");
std::string string1 = "Test String";
std::string string2 (string1);
std::string string3;
string3.assign (cstring);
work well in the driver. But if the same code are placed anywhere in the DLL project, none of string1, string2 and string3 can be assigned with any values successfully. Mostly, the debugger shows them as Bad Ptr. It looks that they are not well allocated in the memory.
I have tried to place the std::string as class member fields, auto variables, and static variables. But none of the methods work as expected. Can anybody help me to find out the cause?