Windows Phone 8 - "Unable to read memory" 在 WindowPhone8 上使用 "FILE* file" (C++) 时

windows phone 8 - "Unable to read memory" When using "FILE* file" (C++) on WindowPhone8

本文关键字:FILE file C++ WindowPhone8 Phone Unable to memory read Windows      更新时间:2023-10-16

我在WP8上使用C++时遇到问题。遇到上面的行时,我的应用程序崩溃。当我调试时,我看到:

 1. All the member of this variable "file" got message:
    (file)->_ptr: Unable to read memory.
    (file)->_cnt: Unable to read memory.
    (file)->_base: Unable to read memory.
    (file)->_flag: Unable to read memory.
    (file)->_file: Unable to read memory.
    (file)->_charbuf: Unable to read memory.
    (file)->_tmpfname: Unable to read memory.
    (file)->_bufsiz: Unable to read memory.

我不知道该怎么修。

这是我使用的代码:

void SubMenu::LoadConfig(float dt)
{
    TiXmlDocument doc;
    bool flag = doc.LoadFile("ConfigConfig.xml");// Error here.
    TiXmlElement* root = doc.FirstChildElement();
    for (TiXmlElement* elem = root->FirstChildElement(); elem != NULL; elem = elem->NextSiblingElement())
    {
        std::string elemName = elem->Value();
        int Star = atoi(elem->GetText());
        if (elemName == "Tractor")
        {
            this->AddStarPoint(Level1, 4, Star);
        }
        if (elemName == "EggsCatch")
        {
            this->AddStarPoint(Level2, 3, Star);
        }
        if (elemName == "EggsCatch2")
        {
            this->AddStarPoint(Level3, 4, Star);
        }
    }
}

这是tinyxml.cpp得到的函数LoadFile:

bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
{
    TIXML_STRING filename( _filename );
    value = filename;
    // reading in binary mode so that tinyxml can normalize the EOL
    FILE* file = TiXmlFOpen( value.c_str (), "rb" ); // Error here. 
    if ( file )
    {
        bool result = LoadFile( file, encoding );
        fclose( file );
        return result;
    }
    else
    {
        SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
        return false;
    }
}

请帮忙!谢谢

我假设file == NULL是因为路径中有一个反斜杠。尝试

  • (更简单)用斜线"Config/Config.xml"替换它,或者
  • (最好)用另一个反斜杠"Config\Config.xml"对其进行转义