>>is that C ? i want to do it in C++ with streams if possible
Writing to stream
Code:
#include <fstream>
#include <list>
using namespace std;
struct fingertip {
int x;
int y;
int c;
};
ostream& operator<<(ostream& os,const fingertip& ft)
{
os << ft.x << ';' << ft.y << ';' << ft.c << '\n';
return os;
}
...
ofstream fileOut("ft.txt");
list<fingertip> lft;
fingertip tf = {1,2,3};
lft.push_back(tf);
lft.push_back(tf);
typedef list<fingertip>::const_iterator ftiter;
for(ftiter i = lft.begin();i != lft.end();++i)
fileOut << *i;
For reading implement the istream operator>> .
Code:
istream& operator>>(istream& is,fingertip& ft)
...