相关疑难解决方法(0)

这段代码有效,还是编译器?

int cpu = 0;
int player = 0;

char * getPoints()
{
    using namespace std;
    string str = "You: ";
    str += player;
    str += " CPU: ";
    str += cpu;
    char c [100];
    strcpy(c, str.c_str());
    return c;
}
Run Code Online (Sandbox Code Playgroud)

此代码无法编译.代码是错误的还是我的编译器有问题?

我使用的是Microsoft Visual StudioDarkGDK.

如果是我,有人可以改善吗?


这是输出:

1>------ Build started: Project: Pong, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>c:\users\martijn\documents\visual studio 2008\projects\pong\pong\main.cpp(42) : warning C4172: returning address of local variable or temporary
1>Linking...
1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' …
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
5704
查看次数

标签 统计

c++ ×1