2010-06-21 5 views
1

다음 응용 프로그램은 첫 줄에 액세스 위반이 있습니다. 그 이유는 무엇입니까?한 줄에 오류가 있습니다. Xerces 프로그램

// test.cpp : Defines the entry point for the console application. 
// 

#include "stdafx.h" 
#include <iostream> 
#include <xercesc/util/XMLString.hpp> 

using namespace xercesc; 

int main() 
{ 

    XMLCh* path= XMLString::transcode("test.xml"); 

    return 0; 
} 

[편집] 다음 코드는 나에게 XMLFormatTarget 라인에 예외를 제공합니다,하지만 난에서 문자열을 변경하는 경우 : "test.xml의"에 "C /test.xml을"그것을 잘 작동합니다.

// test.cpp : Defines the entry point for the console application. 
// 

#include "stdafx.h" 
#include <iostream> 
#include <xercesc/util/XMLString.hpp> 
#include <xercesc/framework/LocalFileFormatTarget.hpp> 

using namespace xercesc; 

int main() 
{ 
    XMLPlatformUtils::Initialize(); 

    XMLFormatTarget *formatTarget = new LocalFileFormatTarget("C:/test.xml"); 

    return 0; 
} 
+0

정상 검사와 마찬가지로 XMLString :: transcode()에 대한 호출을 제거해도 충돌이 발생합니까? – WildCrustacean

답변

1

명백한 오류는 사용하기 전에 xerces-c를 초기화하지 않는다는 것입니다.

http://xerces.apache.org/xerces-c/program-2.html

당신의 Xerces-C에 대한 다른 호출을하기 전에 XMLPlatformUtils::Initialize()를 호출해야합니다.

+0

대단히 감사합니다. Charles, 어쩌면 친절하게도 나를 도와 줄 수있을 것입니다. 새로운 질문으로 원래 질문을 업데이트했습니다. 감사합니다. – Gungho

+0

@ 팀 : 이미이 질문에 대한 답변을 수락 했으므로 새로운 질문은 본래의 문언과 완전히 다릅니다. 새로운 질문으로 질문하는 것이 더 합리적입니다. –

+0

여기에 새로운 질문이 있습니다. http://stackoverflow.com/questions/3091484/exception-in-two-line-xerces-program – Gungho