为什么memcpy不能用阿!
我做了一个动态库。有如下代码:
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
//王志伟声明并修改维护该部分代码
struct C_ReaderInfo
{
public:
int int_value;
char char_value[255];
double float_value;
BOOL bool_value;
char * string_value;
} readerdata;
extern "C" __declspec(dllexport) int add( struct C_ReaderInfo * readerdata, char * tmpstr)
readerdata)
{
int i;
i=strlen (readerdata->string_value);
memcpy(tmpstr, readerdata->string_value,i+1);
char *buf = "another";
int j = strlen ( buf );
char * chp = readerdata->string_value;
strcpy(readerdata->string_value,buf);
return 0;
}
build都没有错误,但是通过外部程序调用该动态库出错,经过
跟踪,发现是到了strcpy函数这里发生错误
不知道为什么?
请各位高手给看看