# From Cinder Asset to ifstream

**URL:** <https://discourse.libcinder.org/t/from-cinder-asset-to-ifstream/1475>\
**Category:** Uncategorized\
**Created:** [April 3, 2019, 11:16am UTC](https://discourse.libcinder.org/t/from-cinder-asset-to-ifstream/1475 "2019-04-03T11:16:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Gazoo](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/gazoo/32/61_2.png) [@Gazoo](https://discourse.libcinder.org/u/Gazoo)\
**Post date:** [April 6, 2019, 4:00am UTC](https://discourse.libcinder.org/t/from-cinder-asset-to-ifstream/1475/2 "2019-04-06T04:00:35Z")

</div>

For those interested, I had some minor issues actually getting saving/loading a `vector<vector<float>>` to and from a file on disk, but I eventually got that sorted. Here’s the complete code which should work:

```
void SaveFeaturesFile( std::vector<std::vector<float>> const& features, std::string filename )
{
	std::ofstream out( filename.c_str(), std::ios::binary );
	boost::archive::binary_oarchive oa( out );
	oa << features;
	out.close();
}

void LoadFeaturesFileFromFile( std::vector<std::vector<float>> &features, std::string filename )
{
	std::ifstream in( filename.c_str(), std::ios::binary );
	boost::archive::binary_iarchive ia( in );
	ia >> features;
	in.close();
}

```

Note, this **is platform dependent** due to the data being stored in binary!

I also came across this [previous topic](https://discourse.libcinder.org/t/create-a-stringstream-from-cinder-buffer-avoiding-copying/153) which elaborates a bit on how to create `std::stringstream` from a cinder `buffer`, but I’ve yet to grasp how to work things out for binary data.

Cheers,  
Gazoo

---

_[View the full topic](https://discourse.libcinder.org/t/from-cinder-asset-to-ifstream/1475)._
