返回与本地变量关联的堆栈内存的地址(C++)

Vol*_*ort -2 c++

Mac OSX,我正在尝试使用tchar.h,但显然是Windows特有的.而且我猜这是代码不适合我的原因:

//toString

char *Node::toString(){

    char hilera[100];
    strcpy(hilera, dato->toString());
    strcat(hilera, "\n");
    return hilera;


}
Run Code Online (Sandbox Code Playgroud)

所以你有什么建议?

For*_*veR 6

退出函数范围hilera后将被销毁,将返回悬空指针.std::string在堆中使用或分配内存.