Skip to content
Snippets Groups Projects
Commit 6305ac11 authored by Arseny Kapoulkine's avatar Arseny Kapoulkine
Browse files

docs: Fix samples compilation

git-svn-id: https://pugixml.googlecode.com/svn/trunk@992 99668b35-9821-0410-8761-19e4c4f06640
parent e33e1083
No related branches found
No related tags found
No related merge requests found
#include "pugixml.hpp" #include "pugixml.hpp"
#include <iostream> #include <iostream>
#include <cstring>
int main() int main()
{ {
......
#include "pugixml.hpp" #include "pugixml.hpp"
#include <string> #include <string>
#include <iostream>
#include <stdio.h> #include <cstring>
//[code_save_custom_writer //[code_save_custom_writer
struct xml_string_writer: pugi::xml_writer struct xml_string_writer: pugi::xml_writer
...@@ -97,19 +97,19 @@ int main() ...@@ -97,19 +97,19 @@ int main()
doc.load("<foo bar='baz'>hey</foo>"); doc.load("<foo bar='baz'>hey</foo>");
// get contents as std::string (single pass) // get contents as std::string (single pass)
printf("contents: [%s]\n", node_to_string(doc).c_str()); std::cout << "contents: [" << node_to_string(doc) << "]\n";
// get contents into fixed-size buffer (single pass) // get contents into fixed-size buffer (single pass)
char large_buf[128]; char large_buf[128];
printf("contents: [%s]\n", node_to_buffer(doc, large_buf, sizeof(large_buf))); std::cout << "contents: [" << node_to_buffer(doc, large_buf, sizeof(large_buf)) << "]\n";
// get contents into fixed-size buffer (single pass, shows truncating behavior) // get contents into fixed-size buffer (single pass, shows truncating behavior)
char small_buf[22]; char small_buf[22];
printf("contents: [%s]\n", node_to_buffer(doc, small_buf, sizeof(small_buf))); std::cout << "contents: [" << node_to_buffer(doc, small_buf, sizeof(small_buf)) << "]\n";
// get contents into heap-allocated buffer (two passes) // get contents into heap-allocated buffer (two passes)
char* heap_buf = node_to_buffer_heap(doc); char* heap_buf = node_to_buffer_heap(doc);
printf("contents: [%s]\n", heap_buf); std::cout << "contents: [" << heap_buf << "]\n";
delete[] heap_buf; delete[] heap_buf;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment