RapidXml reading xml files

I'm using RapidXml 1.13 (http://rapidxml.sourceforge.net/) library with VisualStudio 2013 VC++ to read and edit xml file as mentioned in this tutorial (http://spin.atomicobject.com/2012/05/20/rapidxml-a-lightweight-xml-library-for-c/)

Here is my code to read xml file,

xml_document<> doc;
string xmlFilePath = "D:/xml/xyz.xml";
ifstream file(xmlFilePath);

vector<char> buffer((istreambuf_iterator<char>(file)), istreambuf_iterator<char>());
buffer.push_back('\0');

But compiler gives me errors in buffer.push_back('\0'),
1. error C2040: 'buffer' : 'std::vector>' differs in levels of indirection from 'char [200]'
2. error C2228: left of '.push_back' must have class/struct/union
3. IntelliSense: expression must have class type

How to solve this error ?
#include <vector>
#include <iterator>


And qualify names from the standard library with std::

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <iterator>

int main()
{
    const std::string xmlFilePath = "D:/xml/xyz.xml";
    
    std::ifstream file(xmlFilePath);

    std::vector<char> buffer( ( std::istreambuf_iterator<char>(file) ), std::istreambuf_iterator<char>() );
    
    // simpler: http://www.stroustrup.com/C++11FAQ.html#uniform-init
    std::vector<char> buffer2{ std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>() } ;
    
    buffer.push_back(0) ; 
    buffer2.push_back(0) ;
    
    std::cout << "msc++ version: " << _MSC_VER << '\n' ;
}

http://rextester.com/XBK24796
using above solution solved my problem thanks
Topic archived. No new replies allowed.