Guest User

Untitled

a guest
Nov 20th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. #include<fstream.h>
  2. #include<stdio.h>
  3. #include<string.h>
  4. #include<conio.h>
  5.  
  6. struct up{
  7. char user[20];
  8. char pwd[15];
  9. char mno[10];
  10. char ban[12];
  11. } up1;
  12.  
  13. class login{
  14. public:
  15. void getregster();
  16. void signin();
  17.  
  18. char un1[20];
  19. char pw1[15];
  20. char rpw1[15];
  21. char mno1[10];
  22. char ban1[12];
  23. };
  24.  
  25. void login::getregster(){
  26. clrscr();
  27. cout<<"USERNAME: \t";
  28. gets(un1);
  29. int passflag = 0;
  30. do{
  31. if(passflag) cout << "Passwords do not match\n";
  32. passflag = 1;
  33. cout<<"\nPassword: \t";
  34. gets(pw1);
  35. cout<<"\nConfirm password: \t";
  36. gets(rpw1);
  37. } while(strcmp(pw1, rpw1) != 0);
  38.  
  39. int numflag = 0;
  40. do{
  41. if(numflag) cout << "Not a valid number\n";
  42. numflag = 1;
  43. cout<<"\nMobile Number: \t";
  44. gets(mno1);
  45. } while(strlen(mno1) != 10);
  46.  
  47. cout<<"\nBank Account Number:\t";
  48. gets(ban1);
  49. cout<<"\npress any key";
  50. getch();
  51.  
  52. strcpy(up1.user, un1);
  53. strcpy(up1.pwd, pw1);
  54. strcpy(up1.mno, mno1);
  55. strcpy(up1.ban, ban1);
  56.  
  57. fstream in1;
  58. in1.open("record.dat",ios::binary|ios::app);
  59. in1.write((char*)&up1,sizeof(up1));
  60.  
  61. cout<<" Account Created :)";
  62. }
  63.  
  64. void login::signin(){
  65. char un2[20];
  66. char pw2[15];
  67. clrscr();
  68. cout<<"USERNAME: \t";
  69. gets(un2);
  70. cout<<"\nPassword: \t";
  71. gets(pw2);
  72. fstream in2;
  73. in2.open("record.dat",ios::binary|ios::app);
  74. while(in2){
  75. in2.read((char*)&up1,sizeof(up1));
  76.  
  77. if(in2.eof()){
  78. cout<<"\nincorrect username or password";
  79. break;
  80. }
  81. if((strcmpi(un2,up1.user)==0)&&(strcmpi(up1.pwd,pw2)==0)){
  82. cout<<"\nsigned in!";
  83. break;
  84. }
  85. }
  86. }
  87.  
  88.  
  89. void main(){
  90. clrscr();
  91. login l;
  92. cout<<"\n *** WELCOME TO PAYTM ***";
  93. int n;
  94. cout<<"\n Please choose an option:\n1:Log In \n2:New User? Sign up\n";
  95. cin>>n;
  96. switch(n){
  97. case 1:
  98. l.signin();
  99. break;
  100. case 2:
  101. l.getregster();
  102. break;
  103. default:
  104. cout<<"\n you did not choose a valid option"<<endl;
  105. }
  106.  
  107. getch();
  108. }
Add Comment
Please, Sign In to add comment