diff --git a/C++/.dat b/C++/.dat new file mode 100644 index 000000000..a817b71d9 Binary files /dev/null and b/C++/.dat differ diff --git a/C++/17thMarch-prabhat.cpp b/C++/17thMarch-prabhat.cpp new file mode 100644 index 000000000..748824a87 --- /dev/null +++ b/C++/17thMarch-prabhat.cpp @@ -0,0 +1,92 @@ +#include +#include +#include +#include +#include + +struct user +{ + char phone[50]; + char ac[50]; + char password[50]; + float balance; +}; +int main() + +{ + system("cls"); + system("color 3"); + struct user usr; + FILE *fp; + char filename[50], phone[50], pword[50]; + char cont = 'y'; + int opt, choice; + + printf("=====BANKING AUTHENTICATION SYSTEM===="); + printf("\n\nWhat do you want to do?\n"); + printf("\n1.Register an account "); + printf("\n2.Login to account\n"); + printf("\nYour choice:\t"); + + scanf("%d", &opt); + if (opt == 1) + { + + printf("Enter your account no:\t"); + scanf("%s", usr.ac); + printf("Enter your phone no:\t"); + scanf("%s", usr.phone); + printf("Enter your password:\t"); + scanf("%s", usr.password); + usr.balance = 0; + strcpy(filename, usr.phone); + fp = fopen(strcpy(filename, ".dat"), "w"); + fwrite(&usr, sizeof(struct user), 1, fp); + if (fwrite != 0) + { + printf("\n Account is successfully created"); + } + else + { + printf("\n Something went wrong please try again later"); + } + fclose(fp); + } + if (opt == 2) + { + printf("\nPhone Number:\t"); + scanf("%s", phone); + printf("Password:\t"); + scanf("%s", pword); + strcpy(filename, phone); + fp = fopen(strcat(filename, ".dat"), "r"); + if (fp = NULL) + { + printf("\n Account is not registered."); + } + else + { + fread(&usr, sizeof(struct user), 1, fp); + fclose(fp); + if (!strcmp(pword, usr.password)) + { + while (cont == 'y') + { + printf("\nPress 1 for balance inquiry"); + printf("\nPress 1 for depositing cash"); + printf("\nPress 1 for online transfer"); + printf("\nPress 1 for password change"); + + printf("\n Do you want to continue the transaction('Y/N')"); + scanf("%s", &cont); + } + } + else + { + printf("\nInvalid password"); + } + } + } + + return 0; +} \ No newline at end of file diff --git a/C++/17thMarch-prabhat.exe b/C++/17thMarch-prabhat.exe new file mode 100644 index 000000000..40b1dcb85 Binary files /dev/null and b/C++/17thMarch-prabhat.exe differ