Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<fstream.h>
- #include<stdio.h>
- #include<string.h>
- #include<conio.h>
- struct up{
- char user[20];
- char pwd[15];
- char mno[10];
- char ban[12];
- } up1;
- class login{
- public:
- void getregster();
- void signin();
- char un1[20];
- char pw1[15];
- char rpw1[15];
- char mno1[10];
- char ban1[12];
- };
- void login::getregster(){
- clrscr();
- cout<<"USERNAME: \t";
- gets(un1);
- int passflag = 0;
- do{
- if(passflag) cout << "Passwords do not match\n";
- passflag = 1;
- cout<<"\nPassword: \t";
- gets(pw1);
- cout<<"\nConfirm password: \t";
- gets(rpw1);
- } while(strcmp(pw1, rpw1) != 0);
- int numflag = 0;
- do{
- if(numflag) cout << "Not a valid number\n";
- numflag = 1;
- cout<<"\nMobile Number: \t";
- gets(mno1);
- } while(strlen(mno1) != 10);
- cout<<"\nBank Account Number:\t";
- gets(ban1);
- cout<<"\npress any key";
- getch();
- strcpy(up1.user, un1);
- strcpy(up1.pwd, pw1);
- strcpy(up1.mno, mno1);
- strcpy(up1.ban, ban1);
- fstream in1;
- in1.open("record.dat",ios::binary|ios::app);
- in1.write((char*)&up1,sizeof(up1));
- cout<<" Account Created :)";
- }
- void login::signin(){
- char un2[20];
- char pw2[15];
- clrscr();
- cout<<"USERNAME: \t";
- gets(un2);
- cout<<"\nPassword: \t";
- gets(pw2);
- fstream in2;
- in2.open("record.dat",ios::binary|ios::app);
- while(in2){
- in2.read((char*)&up1,sizeof(up1));
- if(in2.eof()){
- cout<<"\nincorrect username or password";
- break;
- }
- if((strcmpi(un2,up1.user)==0)&&(strcmpi(up1.pwd,pw2)==0)){
- cout<<"\nsigned in!";
- break;
- }
- }
- }
- void main(){
- clrscr();
- login l;
- cout<<"\n *** WELCOME TO PAYTM ***";
- int n;
- cout<<"\n Please choose an option:\n1:Log In \n2:New User? Sign up\n";
- cin>>n;
- switch(n){
- case 1:
- l.signin();
- break;
- case 2:
- l.getregster();
- break;
- default:
- cout<<"\n you did not choose a valid option"<<endl;
- }
- getch();
- }
Add Comment
Please, Sign In to add comment