如何修复此错误访问冲突读取位置0x00000008 [英] How can I fix this error Access violation reading location 0x00000008

查看:432
本文介绍了如何修复此错误访问冲突读取位置0x00000008的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在0x00814477的第一次例外只有一个more.exe的时间:0xC0000005:访问冲突读取位置0x00000008。
未处理的异常在0x00814477只有一个more.exe:0xC0000005:访问冲突读取位置0x00000008。

First-chance exception at 0x00814477 in Only time for one more.exe: 0xC0000005: Access violation reading location 0x00000008. Unhandled exception at 0x00814477 in Only time for one more.exe: 0xC0000005: Access violation reading location 0x00000008.

//我相信这有什么关系NULL和操作系统,但我不确定如何解决这个

//I believe this has something to do with NULL and the OS but I am unsure how to fix this

GameObject::GameObject()
{
    sprite = NULL;
    pos.x = 0; pos.y = 0;
    vel.x = 0; vel.y = 0;

    framenum  = 0;
    numframes = 0;
}

GameObject::~GameObject()
{
    if ( sprite != NULL )
        SDL_FreeSurface( sprite );
}   

void GameObject::LoadImage(std::string filename)
{
    sprite = IMG_Load( filename.c_str() );
    //clip.x = 0;
    //clip.y = 0;
    clip.w = sprite->w;           //It breaks here 
    clip.h = sprite->h;          // and here 
}


推荐答案

调用:

sprite = IMG_Load( filename.c_str() );

可能返回 NULL 。您应该检查相关文档,了解原因,并更正相关错误。

Is likely returning NULL. You should check the relevant documentation for why that might be and correct the related error.

这篇关于如何修复此错误访问冲突读取位置0x00000008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆