相关疑难解决方法(0)

使用C-string:"返回与本地变量关联的堆栈内存的地址"

我不是C程序员,所以我不熟悉C-string但新的我必须使用C库,所以这里是我的代码的缩短版本来演示我的问题:

char** ReadLineImpl::my_completion () {

    char* matches[1];


    matches[0] = "add";

    return matches;

}
Run Code Online (Sandbox Code Playgroud)

我收到警告:

警告 - 与返回的本地变量"matches"关联的堆栈内存的地址

我的应用程序似乎没有正常工作(可能是因为这个警告).

什么是警告,是否会引起任何问题?

c++ pointers c-strings

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

标签 统计

c++ ×1

c-strings ×1

pointers ×1