我有个问题。我需要创建以下xml:
<?xml version="1.0" encoding="utf-8"?>
<MyApp value="5" name="me">
</MyApp>
Run Code Online (Sandbox Code Playgroud)
使用c ++代码,我执行了以下操作:
#include <iostream>
#include <string>
#include "tinyxml.h"
void main(){
TiXmlDocument doc;
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "utf-8", "");
doc.LinkEndChild( decl );
TiXmlElement * root;
root = new TiXmlElement( "MyApp" );
root->SetAttribute("value","5");
root->SetAttribute("name","me");
doc.LinkEndChild( root );
doc.SaveFile( "madeByHand.xml" );
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我使用g ++ tinyxml.cpp tinyxmlerror.cpp和tinyxmlparser.cpp编译它。当我想查看我创建的XML时。我有一个错误:它说没有写清楚。我在哪里错?:)
你能告诉我如何将buf矢量的大小改成动态长度吗?
long five = 555;
char buf[256];
snprintf(buf, sizeof(buf), "%d", five);
Run Code Online (Sandbox Code Playgroud)
谢谢!
如何更改我的代码std::vector<std::string>buf;才能正常工作?
我有错误:
vector不是std的成员;
buf未在此范围和错误中声明:在">"标记之前预期的primary-expression