gpt4 book ai didi

c++ - 试图读取或写入 protected 内存 : C++ Modified Value of Memory

转载 作者:行者123 更新时间:2023-11-28 06:21:58 25 4
gpt4 key购买 nike

<分区>

我为修剪字符串“C 和 C++ 中的字符数组或字符指针”使用此函数:

inline char * trimRight(char * str)
{
char * end = str + strlen(str);
while(str != end)
{
end--;
switch(*end)
{
case ' ':
case '\t':
case '\n':
case '\v':
case '\f':
case '\r':
break;
default:
*(end+1) = '\0';
return end+1;
}
}
return str;
}

但返回此错误(代码 *(end+1) = '\0' 中的原因):

An unhandled exception of type 'System.AccessViolationException' occurred in x.exe

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

请帮助我。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com