How to use ofBuffer to append to a file


I’m trying to save a few values to xml (via ofxXmlSettings).
I’d like to leave an oF app running and while it does, append values to an xml node.

I’ve got something like this:

//called once on setup()"stream.xml"), ofFile::Append, false);  
//called multiple times on update()  
string trackStr = ofToString(trackXML);  
//trackBuffer.set(const char *_buffer, <#int _size#>) //how do I plug the xml to the buffer  
//called once on event  

Unfortunately I’m not experienced with File I/O in c++/oF
so any hints/tips would help.


If your using ofxXmlSettings you don’t need to manually write to an ofFile, you just set the values. Have you seen the xmlSettingsExample in the addonsExamples folder?

But, if you are wanting to manually write to an ofFile, you can try something like this…“yourfile.xml”, ofFile::WriteOnly);
file << “10” + “\n”;

That’s pretty cool! I need to learn by basics (File I/O) :slight_smile:
Thank you for this