Access violation
От: Аноним  
Дата: 09.02.11 08:14
Оценка: :))
Помогите, что-то туплю...

Код:

void ReplaceNULL(wchar_t *str, const wchar_t *strSearch, size_t size)
{
    wchar_t *p = wcsstr(str, strSearch);
    if (p)
    {
        // Unhandled exception 0xC0000005: Access violation writing location 0x00417bfa.
        *p = ' ';
        *(p+size-1) = ' ';
    }
}

#define NULL_STRING L"'NULL'"
#define null_string L"'null'"

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
    wchar_t *buff = L"insert into table ([Id], [Name], [Value]) values (1, 'Name', 'NULL')";
    ReplaceNULL(buff, NULL_STRING, sizeof(NULL_STRING)/sizeof(wchar_t)-1);
    ReplaceNULL(buff, null_string, sizeof(null_string)/sizeof(wchar_t)-1);

    return 0;
}


В строчке *p = ' ' происходит Access violation..
Что тут не так????

С Уважением,
Александр.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.