小编Edv*_*nka的帖子

尝试在指向值时读取或写入受保护的内存

我有这个代码:

typedef struct {
    string fName;
    string str; 

}t;

//-------Other functions------//
void BeginTh()
{
    string arg = "yes";
    t *arglist;
    arglist = (t*)malloc(sizeof(t));
    arglist->fName = "comBomber";
    arglist->str = arg;
    _beginthread(startOver, 0, (void*)arglist);
    free(arglist);
}
Run Code Online (Sandbox Code Playgroud)

在'arglist-> fName ="comBomber";' 我收到此错误:

An unhandled exception of type 'System.AccessViolationException' occurred in <appname>

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Run Code Online (Sandbox Code Playgroud)

有人可以帮帮我吗?怎么解决这个问题?

谢谢.

c++ compiler-errors

5
推荐指数
2
解决办法
3251
查看次数

标签 统计

c++ ×1

compiler-errors ×1