Saving data

Hi,

I'm writing a windows application which should save and read data like this:


Name      Password    Birtday       Allowed to do... Allowed to do...
Jim       1458        12-12-1995    TRUE             FALSE
Jessica   5542        01-06-1981    TRUE             TRUE
James     4471        etc...


I found something in the msnd library (http://msdn.microsoft.com/en-us/library/y2ad8t9c.aspx) which seams perfectly suitable, but it looks quite extensive for the job I want to use it for. So are there other (simpler) ways of doing this (is it possible with streams?) and where can I find these?
output everything in a file in a way that you can easily read it back.
A simple format would be one information per line so you can use getline to get it back.
take this simplified pseudocode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
struct S
{
    string name;
    int password;
};

void save ()
{
    open file
    for each S
        file << name << '\n' << password << '\n'; 
}

void read ()
{
    open file
    for each S
        getline ( file, name ); 
        getline ( file, temp );
        stringstream ( temp ) >> password; 
}


The resulting file would be something like this:
Jim
1458
Jessica
5542
...
Ok, I'll try, but isn't it a problem that I don't know the number of colombs and rows?

And isn't there a (file) format in which I can save it like kind of an excel sheet?
Try XML. You should use an external library for that.
Boost property tree is one: http://www.boost.org/doc/libs/1_42_0/doc/html/boost_propertytree/parsers.html
The simplest Excel compatible file is a CSV file, where a record occuplies a line with comma delimted fields. That aside, it's plain text and simple.
Topic archived. No new replies allowed.