因为是新手刚学习tinyxml,所以谢了个生成xml文件的cpp试试,编译时没问题,但是程
序运行时会出现:
xml: malloc.c:2395: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
已放弃 (核心已转储)
下面是我的xml.cpp代码:
#include"tinyxml/tinyxml.h"
#include<iostream>
void WrittingXML();
int main()
{
WrittingXML();
return 0;
}
void WrittingXML()
{
TiXmlDeclaration * xmlDec = new TiXmlDeclaration("1.0", "UTF-8", "yes");
TiXmlDocument * xmlDocs = new TiXmlDocument();
xmlDocs->LinkEndChild(xmlDec);
TiXmlElement * element = new TiXmlElement("Document");
xmlDocs->LinkEndChild(element);
TiXmlComment * comment = new TiXmlComment(" This is a list of new books ");
element->LinkEndChild(comment);
TiXmlElement * book = new TiXmlElement("Book");
book->SetAttribute("Name", "How to use TinyXML");
element->LinkEndChild(book);
TiXmlElement * author = new TiXmlElement("Author");
TiXmlText * Authortext = new TiXmlText("Leezhm");
author->LinkEndChild(Authortext);
book->LinkEndChild(author);
TiXmlElement * date = new TiXmlElement("Date");
TiXmlText * Datetext = new TiXmlText("2009-3-30");
date->LinkEndChild(Datetext);
book->LinkEndChild(date);
xmlDocs->SaveFile("test.xml");
delete xmlDocs;
}
因为我没有#define TIXML_USE_STL 所以用的是TiXmlSring类。
但是如果我#define TIXML_USE_STL 的话编译出来的程序就没问题。
求大神赐教啊啊啊啊啊啊啊啊啊啊啊!!!!
不胜感激!!!!!