MapDll.dll中有一个函数
int __stdcall map(string arr[])
{
string temp[] = {"yes", "no"};
arr[0] = "yes"; // right
arr[0] = temp[0]; // error
}
exe中:
string arr[] = {"no", "yes"};
.....
error的那种赋值方式会报错,请指点,谢谢!
int __stdcall map(string arr[])
{
string temp[] = {"yes", "no"};
arr[0] = "yes"; // right
arr[0] = temp[0]; // error
}
exe中:
string arr[] = {"no", "yes"};
.....
error的那种赋值方式会报错,请指点,谢谢!
#include "string.h"
吗?
#include <string>赋值字符串常量没问题
可能是跟 exe 中的内存分配 和 dll 中的内存分配有关系
arr[0] = "yes"; // right
arr[0] = temp[0].c_str(); // 此处有修改是此处的temp数组的析构造成的,用c_str()直接调用string 的operator=().
To: superlym2005()
你说这种方法是对的,但你的解释我还不是很理解,什么时间有空的话,麻烦解释详细点好吗?谢谢!
出错都是活该
哥们很细心呀,骂的好,呵呵。