1
2
3#include<iostream>
4#include<fstream>
5using namespace std;
6
7struct mail
8{
9 char un[50]; // user name
10 char pd[50]; // passsword
11 void reg(int);
12} obj[5];
13
14void mail::reg(int k)
15{
16 int i=k;
17 cout<<"\nEnter user name :: ";
18 cin>>un;
19 cout<<"\nEnter password :: ";
20 cin>>pd;
21
22 ofstream filout;
23 filout.open("C:\\Users\\acer\\Documents\\registration.txt",ios::app|ios::binary);
24 if(!filout)
25 {
26 cout<<"\nCannot open file\n";
27 }
28 else
29 {
30 cout<<"\n";
31 filout.write((char *)&obj[i],sizeof(mail));
32 filout.close();
33 }
34
35 cout<<"\n...........You are now registered.......... \n\n";
36
37} // end of sign up or register func
38
39int main()
40{
41 int t;
42 cout<<"\nEnter Registration Details for User 1 :: \n";
43 obj[0].reg(0);
44 cout<<"\nEnter Registration Details for User 2 :: \n";
45 obj[1].reg(1);
46 cout<<"\nEnter Registration Details for User 3 :: \n";
47 obj[2].reg(2);
48
49 mail obj2;
50
51 ifstream filein;
52 filein.open("C:\\Users\\acer\\Documents\\registration.txt",ios::in|ios::binary);
53 if(!filein)
54 {
55 cout<<"\nUnable to open file to read\n";
56 }
57 else
58 {
59 cout<<"\nRegistered Details of All Users :: \n";
60 filein.read((char *)&obj2,sizeof(obj2));
61 while(filein)
62 {
63 cout<<"\nUsername :: "<<obj2.un<<"\nPasswword :: "<<obj2.pd<<"\n";
64 filein.read((char *)&obj2,sizeof(obj2));
65 }
66 //filein.close();
67 }
68 return 0;
69}
70
1
2#include<iostream>
3#include<fstream>
4using namespace std;
5
6struct mail
7{
8 char un[50]; // user name
9 char pd[50]; // passsword
10 void reg(int);
11} obj[5];
12
13void mail::reg(int k)
14{
15 int i=k;
16 cout<<"\nEnter user name :: ";
17 cin>>un;
18 cout<<"\nEnter password :: ";
19 cin>>pd;
20
21 ofstream filout;
22 filout.open("C:\\Users\\acer\\Documents\\registration.txt",ios::app|ios::binary);
23 if(!filout)
24 {
25 cout<<"\nCannot open file\n";
26 }
27 else
28 {
29 cout<<"\n";
30 filout.write((char *)&obj[i],sizeof(mail));
31 filout.close();
32 }
33
34 cout<<"\n...........You are now registered.......... \n\n";
35
36} // end of sign up or register func
37
38int main()
39{
40 int t;
41 cout<<"\nEnter Registration Details for User 1 :: \n";
42 obj[0].reg(0);
43 cout<<"\nEnter Registration Details for User 2 :: \n";
44 obj[1].reg(1);
45 cout<<"\nEnter Registration Details for User 3 :: \n";
46 obj[2].reg(2);
47
48 mail obj2;
49
50 ifstream filein;
51 filein.open("C:\\Users\\acer\\Documents\\registration.txt",ios::in|ios::binary);
52 if(!filein)
53 {
54 cout<<"\nUnable to open file to read\n";
55 }
56 else
57 {
58 cout<<"\nRegistered Details of All Users :: \n";
59 filein.read((char *)&obj2,sizeof(obj2));
60 while(filein)
61 {
62 cout<<"\nUsername :: "<<obj2.un<<"\nPasswword :: "<<obj2.pd<<"\n";
63 filein.read((char *)&obj2,sizeof(obj2));
64 }
65 //filein.close();
66 }
67 return 0;
68}
69}
70