这里是我的代码部分:副本的char *为char *
extern "C" REGISTRATION_API int extreme(char* lKey)
{
string s1;
char *p=NULL;
try
{
ifstream myfile ("extreme.txt");
int i=0;
if (myfile.is_open())
{
while (getline(myfile,s1))
{
switch (i)
{
case 1:
strcpy(p,s1.c_str());
lKey=p;
break;
//continue here
}
}
}
}
现在,当我打电话从外部应用这个功能,我得到这个错误:
AccessViolationException:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
的问题是由于这样的:
lKey=p;
我如何分配给lKey
p
?
你在哪里分配内存到指针p? – 2010-07-15 14:29:05