C++代码编译但在运行时失败

标签 c++ visual-c++

下面的代码可以编译,但在点击第一个按钮后,它会因 msg 而中断

deming.exe 中 0x0133ae9a 处的未处理异常:0xC0000005:访问冲突写入位置 0x014aedbd。

我是新手,是c++错误还是我用的是dragonsdk?

//====================================================
// App.cpp
//====================================================
#include "DragonFireSDK.h"
#include <string.h>

int Picture;

int OnClick(int value)
{
    char* image = "Images/image";
    image = strcat(image,"_");
    Picture = PushButtonAdd(image, 10, 100, OnClick, 1);
    return 0;
}

void AppMain()
{
    // Application initialization code goes here.  Create the items / objects / etc.
    // that your app will need while it is running.

    Picture = PushButtonAdd("Images/Logo", 10, 100, OnClick, 1);

}

最佳答案

你在这里失败了:

char* image = "Images/image";
image = strcat(image,"_");

您正在尝试修改常量字符串。

关于C++代码编译但在运行时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7438708/

相关文章:

c++ - 在移动设备上缩放 2D 游戏?

c# - 如何解决 "Native DLL libmbusmaster.dll is missing! Please deploy the DLL file into the same directory as mbusmaster.net.dll."的问题

.net - 将 VC 6.0 应用程序移植到 VS 2003 VC++ 应用程序

c++ - 在 C++ 中,结构是如何在内存中布局的?

c++ - 如何将类方法的地址转换为 (void *)

c - 如何使用lapack库解决c中矩阵乘法的链接器错误?

c++ - 在C++中获取目录

c++ - 从函数返回引用并修改它

c++ - vtk 类型的数组拒绝在 C++ 中保存内容

c++ - 两个指针什么时候可以比较?