-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProfile.h
121 lines (101 loc) · 2.65 KB
/
Profile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <iostream>
#include<fstream>
#include<iomanip>
using namespace std;
//class profile
class Profile :public LoginSignup
{
public:
Profile();
Profile(string c1, string c2, string name);
};
Profile::Profile(string c1, string c2, string name)
{
string file_name, file_pass, fav[5], fav2;
bool exist=false;
ofstream newfile;
ifstream oldfile;
string usefav[5];
//fetching data from old file
oldfile.open("profile.txt");
newfile.open("prof.txt"); //new file to transfer data from old to new
//fetching data from old file
while (!oldfile.eof())
{
getline(oldfile, file_name, ',');
getline(oldfile, file_pass, ',');
for(int i=0;i<5;i++)
{
getline(oldfile, fav[i], ',');
}
getline(oldfile, fav2, '\n');
//the present user's data will be altered...
//assigning fav currencies to a local string array
if (file_name == name)
{
for (int i = 0; i < 5; i++)
{
usefav[i] = fav[i]; //storing data to a local array fro later use
}
//sending the recent currencies to user profile
//the two recenty currencies will be send from here
newfile << file_name << "," << file_pass << "," << c1 << "," << c2 << ",";
for (int i = 0; i < 3; i++)
{
//and the old currenices such as on no # 3,4,5 will be send as it is
newfile << fav[i] << ",";
}
newfile << "\n";
}
//rest will be transfer as it is
else
{
newfile << file_name << "," << file_pass << ",";
cout<<file_pass<<endl;
for (int i = 0; i < 5; i++)
{
newfile << fav[i] << ",";
}
newfile << "\n";
if(oldfile.eof())
break;
}
}
//closing files
oldfile.close();
newfile.close();
//renaming files
remove("profile.txt");
rename("prof.txt", "profile.txt");
system("cls");
cout << "Upgrading Profile..Please Wait\n\n\n";
for (int i = 0; i < 200; i++)
{
cout<<"\r..";
}
system("pause");
system("cls");
cout << "Upgrading Done...\n\n";
cout << "*******************************************************************************" << endl;
system("pause");
system("cls");
//displaying profile again
cout << "\t\tWelcome " << name << endl;
cout << "*******************************************************************************" << endl;
cout << "\nFav currencies: " << endl << endl;
cout << c1 << "\n" << c2 << " \n";
//loop for showing currencies
for (int i = 0; i < 3; i++)
{
for(int j=0;j<i;j++)
{
if(usefav[j]==usefav[i] || usefav[j]==c1 || usefav[j]==c2 || usefav[i]=="NULL")
{
exist=true;
break;
}
}
if(exist==false)
cout << usefav[i] << "\n";
}
}