这是我的代码部分:
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:
尝试读取或写入受保护的内存。这通常是其他内存已损坏的指示。
lKey=p;
我该如何将
lKey
赋值给p
?