-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.h
72 lines (69 loc) · 1.48 KB
/
user.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
#ifndef USER_H_INCLUDED
#define USER_H_INCLUDED
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
class user
{
protected:
char name[100];
char password[100];
public:
user()
{
strcpy(name," ");
strcpy(password," ");
}
user(char s[],char p[])
{
strcpy(name,s);
strcpy(password,p);
}
void getdata()
{
cout<<"\tEnter your name: ";
cin>>name;
cout<<"\tEnter your password: ";
cin>>password;
}
void displaydata()
{
cout<<"\tName: "<<name<<endl;
cout<<"\tPassword: ";
int l;
l=strlen(password);
for(int i=0; i<l; i++)
{
cout<<"*";
}
cout<<endl;
}
void in(int pn)
{
ifstream ifile;
ifile.open("f.txt",ios::in|ios::out|ios::binary);
ifile.seekg(pn*sizeof(user));
ifile.read((char*)this,sizeof(*this));
}
void out()
{
ofstream ofile;
ofile.open("f.txt",ios::app | ios::binary);
ofile.write((char*)this, sizeof(*this));
}
bool operator ==(user uu) const
{
if((strcmp(name,uu.name)==0) && (strcmp(password,uu.password)==0))
{
// cout<<"kaisa"<<endl;
return true;
}
else
{
// cout<<"na"<<endl;
return false;
}
}
};
#endif // USER_H_INCLUDED