부스트의 속성 트리를 사용하여 XML 파일을 구문 분석하려고했지만 문자열 값을 가져올 때마다 액세스 위반 예외가 발생합니다. 그것은 정수와 잘 작동하므로 약간 혼란 스럽습니다. 다음 코드의 일부입니다 :부스트 속성 트리 액세스 위반
class Config
{
char * test;
int test2;
public:
Config();
};
Config::Config(void)
{
boost::property_tree::ptree pt;
boost::property_tree::xml_parser::read_xml("config.xml", pt);
try
{
test = pt.get<char*>("base.char");
test2 = pt.get<int>("base.int");
}
catch(std::exception e)
{
//something wasn't specified
}
}
그리고 XML 파일 :
<base>
<char>test</char>
<int>10</int>
</base>
먼저 내가 문자열하지만 둘의 malloc()이나 새 문자 []에 대한 공간을 할당하지 않았기 때문에 그것의 생각 도와 줬어.
도움을 주시면 감사하겠습니다. 미리 감사드립니다 :)
'pt.get ("base.char");'을 사용해 보셨습니까? –
tehlexx