86e57d136a9806c875ba5d23ae4c69ea1ed0f642
[adress.git] / file.cpp
1 #include <fstream>
2 #include <string>
3 #include "functions.h"
4 #include <iostream>
5
6 void load()
7 {
8         ifstream in("/root/.adress");
9         
10         while (!in.eof())
11         {
12                 string fname;
13                 string lname;
14                 string adr;
15                 string pn;
16                 getline(in, fname);
17 //              cout << "Skapar " << fname << "\n";
18 //              cin.get();
19                 getline(in, lname);
20                 getline(in, adr);
21                 getline(in, pn);
22                 if (fname == "" && lname == "" && lname == "" && pn == "")
23                         continue;
24                 (void) new CContact(fname, lname, adr, pn);
25         }
26 }
27
28 void save()
29 {
30         ofstream out;
31         out.open("/root/.adress");
32
33         CContact* contact = CContact::getFirst();
34
35         while ( contact != '\0')
36         {
37                 out << contact->firstname() << "\n";
38                 out << contact->lastname() << "\n";
39                 out << contact->adress() << "\n";
40                 out << contact->phoneNumber() << "\n";
41                 contact=contact->getNext();
42         }
43         out.close();
44 }