Вот часть моего кода:копия символ * на символ *
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? –