├── record.bin ├── README.md ├── LICENSE └── main.c /record.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amulifts/bank-management-system-c/HEAD/record.bin -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bank Management System 2 | 3 | A simple implementation of Bank management System in C programming lanaguage completed as a mini project. 4 | 5 | ## Usage 6 | 7 | ```powershell 8 | gcc main.c -o main.exe 9 | ``` 10 | 11 | ## Features 12 | 13 | - Admin mode and user mode 14 | 15 | - View all registered records at once as **admin** 16 | 17 | - Create, read, update and delete records (CRUD) 18 | 19 | - Search for particular record based on **name** or **account** 20 | 21 | - Transaction (balance enquiry, cash deposit, cash withdrawl) 22 | 23 | ## Team 24 | 25 | 26 | 27 | ## License 28 | 29 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Aman Khadka 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | void admin(); 8 | void login(); 9 | void menu(); 10 | void transaction(); 11 | void option(); 12 | void menuexit(); 13 | void chkblnc(); 14 | void deposit(); 15 | void withdrawl(); 16 | void search(); 17 | void search_acc(); 18 | void search_name(); 19 | void view(); 20 | void add(); 21 | void edit(); 22 | void del(); 23 | void about(); 24 | 25 | int verify(); //for verifying admin and user 26 | int chkacc(); 27 | 28 | COORD coord = {0, 0}; 29 | int m,r; //m in main and r in record 30 | 31 | char id[20], password[15]; 32 | 33 | struct record { 34 | char name[25]; 35 | int account; 36 | char phone[15]; 37 | char address[25]; 38 | char email[35]; 39 | char citiz[20]; 40 | double blnc; 41 | char UserID[10]; 42 | } rec; 43 | 44 | void gotoxy(int a, int b) { 45 | coord.X = a; 46 | coord.Y = b; 47 | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); 48 | } 49 | 50 | int main() { 51 | system("color f4"); 52 | gotoxy(43, 4); 53 | printf(" WELCOME TO TBC BANKING SYSTEM "); 54 | gotoxy(50, 8); 55 | printf("ACCOUNT TYPE"); 56 | gotoxy(44, 10); 57 | printf("[1] . ADMINISTRATOR "); 58 | gotoxy(44, 11); 59 | printf("[2] . USER "); 60 | gotoxy(44, 14); 61 | printf("Enter Your Choice .... "); 62 | scanf("%d", &m); 63 | if (m != 1 && m != 2) { 64 | system("cls"); 65 | main(); 66 | } 67 | system("CLS"); 68 | admin(); 69 | return 0; 70 | } 71 | 72 | void admin() { 73 | system("color f4"); 74 | gotoxy(43, 4); 75 | printf(" WELCOME TO TBC BANKING SYSTEM "); 76 | login(); 77 | if (verify() == 1) { 78 | if (m == 1) 79 | menu(); 80 | else 81 | transaction(); 82 | } else if (verify() == 0) { 83 | system("CLS"); 84 | gotoxy(43, 16); 85 | printf("Incorrect Username / Password !!!!"); 86 | admin(); 87 | } 88 | } 89 | 90 | // Takes the user-name and password . 91 | void login() { 92 | int i = 0; 93 | gotoxy(44, 10); 94 | printf("Enter The Username : "); 95 | scanf(" %[^\n]", id); 96 | gotoxy(44, 12); 97 | printf("Enter The Password : "); 98 | scanf(" %[^\n]", password); 99 | } 100 | 101 | // verifies the user-name and password . 102 | int verify() { 103 | char a; 104 | if (m == 1) { 105 | if ((strcmp(id, "admin") == 0 && strcmp(password, "admin") == 0)) { 106 | gotoxy(38, 16); 107 | printf("You Have Successfully Logged In : \" %s \" ", id); 108 | gotoxy(44, 20); 109 | printf("Press any key to continue .... "); 110 | getch(); 111 | return 1; 112 | } else 113 | return 0; 114 | } else if (m == 2) { 115 | if (strcmp(id, "user") == 0 && strcmp(password, "user") == 0) { 116 | gotoxy(38, 16); 117 | printf("You Have Successfully Logged In : \" %s \" ", id); 118 | gotoxy(44, 20); 119 | printf("Press any key to continue .... "); 120 | getch(); 121 | return 1; 122 | } else 123 | return 0; 124 | } 125 | return 0; 126 | } 127 | 128 | // displays the main user interface screen of program . 129 | void menu() { 130 | system("CLS"); 131 | gotoxy(48, 4); 132 | printf("WELCOME TO MAIN MENU"); 133 | gotoxy(44, 8); 134 | printf("[1] . View Customer Accounts"); 135 | gotoxy(44, 9); 136 | printf("[2] . Customer Account Registration"); 137 | gotoxy(44, 10); 138 | printf("[3] . Edit Customer Account"); 139 | gotoxy(44, 11); 140 | printf("[4] . Delete Customer Account"); 141 | gotoxy(44, 12); 142 | printf("[5] . Search Customer Account"); 143 | gotoxy(44, 13); 144 | printf("[6] . Transaction"); 145 | gotoxy(44, 14); 146 | printf("[7] . Log Out !!! "); 147 | gotoxy(44, 15); 148 | printf("[8] . About US "); 149 | gotoxy(43, 20); 150 | printf("Please Enter Your Choice [1-8] : "); 151 | option(); 152 | } 153 | 154 | // takes user choice and goes to desired function . 155 | void option() { 156 | int i; 157 | scanf("%d", &i); 158 | system("CLS"); 159 | switch (i) { 160 | case 1: 161 | view(); 162 | break; 163 | case 2: 164 | add(); 165 | break; 166 | case 3: 167 | edit(); 168 | break; 169 | case 4: 170 | del(); 171 | break; 172 | case 5: 173 | search(); 174 | case 6: 175 | transaction(); 176 | break; 177 | case 7: 178 | menuexit(); 179 | break; 180 | case 8: 181 | about(); 182 | break; 183 | default: 184 | menu(); 185 | } 186 | } 187 | 188 | // module for viewing account details 189 | void view() { 190 | int i = 7; 191 | struct record rec; 192 | FILE *f; 193 | //rb = reading binary 194 | f = fopen("record.bin", "rb"); 195 | gotoxy(40, 3); 196 | printf("CUSTOMERS LIST"); 197 | gotoxy(5, 5); 198 | printf("A/C No."); 199 | gotoxy(13, 5); 200 | printf("Account Name"); 201 | gotoxy(34, 5); 202 | printf("UserID"); 203 | gotoxy(49, 5); 204 | printf("Email Address"); 205 | gotoxy(85, 5); 206 | printf("Phone No."); 207 | gotoxy(99, 5); 208 | printf("Balance"); 209 | gotoxy(5, 6); 210 | // fread() = for reading binary data 211 | // This reads the contents of a structure variable from the file and stores it in the variable rec. 212 | // The fread() function will keep returning 1 until there are records in the file. 213 | // As soon as the EOF is encountered fread() will return a value less than 1 and the condition in the while loop become false and the control comes out of the while loop. 214 | while (fread(&rec, sizeof(rec), 1, f)) { 215 | gotoxy(7, i); 216 | printf("%d", rec.account); 217 | gotoxy(13, i); 218 | printf("%s", rec.name); 219 | gotoxy(34, i); 220 | for (r = 0; r < 10; r++) { 221 | printf("%d", rec.UserID[r]); 222 | } 223 | gotoxy(49, i); 224 | printf("%s", rec.email); 225 | gotoxy(85, i); 226 | printf("%s", rec.phone); 227 | gotoxy(99, i); 228 | printf("$%.2lf", rec.blnc); 229 | i++; 230 | } 231 | // close the file 232 | fclose(f); 233 | int x; 234 | gotoxy(42, i + 5); 235 | printf("Press [Enter] to return back to main menu. "); 236 | x = getch(); 237 | // 13 = '\r' i.e carriage return 238 | if (x == 13) { 239 | menu(); 240 | } else 241 | view(); 242 | } 243 | 244 | //module for adding accounts. 245 | void add() { 246 | char c; 247 | struct record rec; 248 | FILE *f; 249 | //ab = append binary 250 | f = fopen("record.bin", "ab"); 251 | int i = 0, x; 252 | // first we evaluate body and check condition 253 | do { 254 | system("CLS"); 255 | gotoxy(24, 4); 256 | printf("\t\t\tCUSTOMER ACCOUNT REGISTRATION"); 257 | gotoxy(36, 8); 258 | printf("[1] . Enter Your Name : "); 259 | scanf(" %[^\n]", rec.name); 260 | gotoxy(36, 9); 261 | printf("[2] . Enter Your Account Number : "); 262 | scanf(" %d", &rec.account); 263 | gotoxy(36, 10); 264 | printf("[3] . Enter Your Phone Number : "); 265 | scanf(" %[^\n]", rec.phone); 266 | gotoxy(36, 11); 267 | printf("[4] . Enter Your Address : "); 268 | scanf(" %[^\n]", rec.address); 269 | gotoxy(36, 12); 270 | printf("[5] . Enter Your E-mail : "); 271 | scanf(" %[^\n]", rec.email); 272 | gotoxy(36, 13); 273 | printf("[6] . Enter Your Citizenship No.: "); 274 | scanf(" %[^\n]", rec.citiz); 275 | gotoxy(36, 14); 276 | printf("[7] . Enter Amount To Deposit : $"); 277 | scanf(" %lf", &rec.blnc); 278 | for (r = 0; r < 10; r++) { 279 | rec.UserID[r] = rand() % 10; 280 | } 281 | //fwrite() = for writing binary data 282 | //This helps to write contents in a structure variable in the file and stores it in the variable rec. 283 | fwrite(&rec, sizeof(rec), 1, f); 284 | gotoxy(38, 17); 285 | printf("CUSTOMER ACCOUNT REGISTRATION SUCCESSFULL"); 286 | i++; 287 | gotoxy(36, 19); 288 | printf("Do You Want To Add Another Record ? (Y/N) : "); 289 | scanf(" %c", &c); 290 | } while (c == 'Y' || c == 'y'); 291 | fclose(f); 292 | gotoxy(40, 22); 293 | printf("Press any key to return back to main menu. "); 294 | char z = getch(); 295 | if (z == 13) { 296 | menu(); 297 | } 298 | } 299 | 300 | //module to check whether the entered account is in the database or not 301 | int chkacc(int a) { 302 | FILE *f; 303 | f = fopen("record.bin", "rb"); 304 | //check whether we have reached end of file or not 305 | while (!feof(f)) { 306 | fread(&rec, sizeof(rec), 1, f); 307 | 308 | if (a == rec.account) { 309 | fclose(f); 310 | return 1; 311 | } 312 | } 313 | fclose(f); 314 | return 0; 315 | } 316 | 317 | // module for editing details. 318 | void edit() { 319 | FILE *x, *y; 320 | int a, c; 321 | // colon i.e ":" acts as id for goto function 322 | re: 323 | gotoxy(48, 4); 324 | printf(" EDIT CUSTOMER ACCOUNT "); 325 | gotoxy(43, 7); 326 | printf("Enter Your Account Number To Edit : "); 327 | scanf("%d", &a); 328 | if (chkacc(a) == 1) { 329 | x = fopen("record.bin", "rb"); 330 | y = fopen("new.bin", "wb"); 331 | while (fread(&rec, sizeof(rec), 1, x)) { 332 | if (rec.account != a) 333 | fwrite(&rec, sizeof(rec), 1, y); 334 | else if (rec.account == a) { 335 | gotoxy(52, 21); 336 | printf("Account Number Matched. "); 337 | gotoxy(51, 10); 338 | printf("Enter Your Details"); 339 | gotoxy(31, 12); 340 | printf("[1] . Enter Your Name : "); 341 | scanf(" %[^\n]", rec.name); 342 | gotoxy(31, 13); 343 | printf("[2] . Enter Your Account Number : "); 344 | scanf(" %d", &rec.account); 345 | gotoxy(31, 14); 346 | printf("[3] . Enter Your Phone Number : "); 347 | scanf(" %[^\n]", rec.phone); 348 | gotoxy(31, 15); 349 | printf("[4] . Enter Your Address : "); 350 | scanf(" %[^\n]", rec.address); 351 | gotoxy(31, 16); 352 | printf("[5] . Enter Your E-mail : "); 353 | scanf(" %[^\n]", rec.email); 354 | gotoxy(31, 17); 355 | printf("[6] . Enter Your Citizenship No : "); 356 | scanf(" %[^\n]", rec.citiz); 357 | fwrite(&rec, sizeof(rec), 1, y); 358 | } 359 | } 360 | fclose(x); 361 | fclose(y); 362 | } 363 | if (chkacc(a) == 0) { 364 | system("CLS"); 365 | gotoxy(52, 21); 366 | printf("Account Doesn't Exist. "); 367 | goto re; 368 | } 369 | remove("record.bin"); 370 | rename("new.bin", "record.bin"); 371 | gotoxy(45, 21); 372 | printf("CUSTOMER ACCOUNT UPDATE SUCCESSFULL"); 373 | gotoxy(42, 24); 374 | printf("Press any key to return back to main menu . "); 375 | getch(); 376 | menu(); 377 | } 378 | 379 | //module for deleting account 380 | void del() { 381 | FILE *x, *y; 382 | int a, c; 383 | re: 384 | gotoxy(48, 4); 385 | printf(" DELETE CUSTOMER ACCOUNT "); 386 | gotoxy(41, 9); 387 | printf("Enter Your Account Number To Delete : "); 388 | scanf("%d", &a); 389 | if (chkacc(a) == 1) { 390 | x = fopen("record.bin", "rb"); 391 | y = fopen("new.bin", "wb"); 392 | while (fread(&rec, sizeof(rec), 1, x)) { 393 | if (rec.account != a) 394 | fwrite(&rec, sizeof(rec), 1, y); 395 | } 396 | fclose(x); 397 | fclose(y); 398 | x = fopen("record.bin", "wb"); 399 | y = fopen("new.bin", "rb"); 400 | while (fread(&rec, sizeof(rec), 1, y)) 401 | fwrite(&rec, sizeof(rec), 1, x); 402 | fclose(x); 403 | fclose(y); 404 | } else if (chkacc(a) == 0) { 405 | system("CLS"); 406 | gotoxy(51, 15); 407 | printf("Account Doesn't Exist"); 408 | goto re; 409 | } 410 | gotoxy(44, 15); 411 | printf("CUSTOMER ACCOUNT DELETED SUCCESSFULLY"); 412 | gotoxy(42, 18); 413 | printf("Press any key to return back to main menu. "); 414 | getch(); 415 | menu(); 416 | } 417 | 418 | //module for searching account ( 2 types by number and name ) 419 | void search() { 420 | system("cls"); 421 | int a; 422 | gotoxy(55, 4); 423 | printf(" SEARCH MENU "); 424 | gotoxy(49, 10); 425 | printf("[1] . Search By Account "); 426 | gotoxy(49, 12); 427 | printf("[2] . Search By Name "); 428 | gotoxy(47, 17); 429 | printf("Enter Your Choice [1-2] : "); 430 | scanf("%d", &a); 431 | system("cls"); 432 | if (a == 1) { 433 | search_acc(); 434 | } else if (a == 2) { 435 | search_name(); 436 | } else 437 | menu(); 438 | } 439 | 440 | void search_acc() { 441 | FILE *f; 442 | int a, x; 443 | re: 444 | gotoxy(48, 4); 445 | printf(" SEARCH CUSTOMER ACCOUNT "); 446 | gotoxy(43, 7); 447 | printf("Enter Your Account Number To Search : "); 448 | scanf("%d", &a); 449 | if (chkacc(a) == 1) { 450 | f = fopen("record.bin", "rb"); 451 | while (fread(&rec, sizeof(rec), 1, f)) { 452 | if (rec.account == a) { 453 | gotoxy(52, 21); 454 | printf("Account Number Matched. User is Active."); 455 | gotoxy(45, 10); 456 | printf("Detail Information of %s", strupr(rec.name)); 457 | gotoxy(37, 12); 458 | printf("[1] . Account Number : %d", rec.account); 459 | gotoxy(37, 13); 460 | printf("[2] . Name : %s", rec.name); 461 | gotoxy(37, 14); 462 | printf("[3] . UserID : "); 463 | for (r = 0; r < 10; r++) { 464 | printf("%d", rec.UserID[r]); 465 | } 466 | gotoxy(37, 15); 467 | printf("[4] . Phone Number : %s", rec.phone); 468 | gotoxy(37, 16); 469 | printf("[5] . Address : %s", rec.address); 470 | gotoxy(37, 17); 471 | printf("[6] . E-mail : %s", rec.email); 472 | gotoxy(37, 18); 473 | printf("[7] . Citizenship No : %s", rec.citiz); 474 | gotoxy(37, 19); 475 | printf("[8] . Current Balance: $%.2lf", rec.blnc); 476 | break; 477 | } 478 | } 479 | fclose(f); 480 | } 481 | if (chkacc(a) == 0) { 482 | system("CLS"); 483 | gotoxy(52, 21); 484 | printf("Account Doesn't Exist. User is Inactive. "); 485 | goto re; 486 | } 487 | gotoxy(42, 24); 488 | printf("Press [ENTER] to return back to main menu. "); 489 | char z = getch(); 490 | if (z == 13) 491 | menu(); 492 | else 493 | search(); 494 | } 495 | 496 | void search_name() { 497 | int i = 0, b, x; 498 | char nam[30]; 499 | gotoxy(48, 4); 500 | printf(" SEARCH CUSTOMER ACCOUNT "); 501 | gotoxy(43, 7); 502 | printf("Enter Your Full Name To Search : "); 503 | scanf(" %[^\n]", nam); 504 | FILE *f; 505 | f = fopen("record.bin", "rb"); 506 | while (fread(&rec, sizeof(rec), 1, f)) { 507 | b = 0; 508 | strupr(rec.name); 509 | strupr(nam); 510 | if (strcmp(rec.name, nam) == 0) { 511 | gotoxy(52, 21); 512 | printf("Account Number Matched. User is Active."); 513 | gotoxy(45, 10); 514 | printf("Detail Information of %s", rec.name); 515 | gotoxy(37, 12); 516 | printf("[1] . Account Number : %d", rec.account); 517 | gotoxy(37, 13); 518 | printf("[2] . Name : %s", rec.name); 519 | gotoxy(37, 14); 520 | printf("[3] . UserID : "); 521 | for (r = 0; r < 10; r++) { 522 | printf("%d", rec.UserID[r]); 523 | } 524 | gotoxy(37, 15); 525 | printf("[4] . Phone Number : %s", rec.phone); 526 | gotoxy(37, 16); 527 | printf("[5] . Address : %s", rec.address); 528 | gotoxy(37, 17); 529 | printf("[6] . E-mail : %s", rec.email); 530 | gotoxy(37, 18); 531 | printf("[7] . Citizenship No : %s", rec.citiz); 532 | gotoxy(37, 19); 533 | printf("[8] . Current Balance: $%.2lf", rec.blnc); 534 | break; 535 | } else 536 | b = 1; 537 | } 538 | fclose(f); 539 | if (b == 1) { 540 | system("cls"); 541 | gotoxy(52, 21); 542 | printf("Account Doesn't Exist. User is Inactive."); 543 | search_name(); 544 | } 545 | gotoxy(42, 24); 546 | printf("Press [ENTER] to return back to main menu. "); 547 | char z = getch(); 548 | if (z == 13) 549 | menu(); 550 | else 551 | search(); 552 | } 553 | 554 | // displays screen for the transaction options and takes the user choice . 555 | void transaction() { 556 | system("CLS"); 557 | gotoxy(48, 4); 558 | printf(" TRANSACTION MENU "); 559 | gotoxy(49, 9); 560 | printf("[1] . Balance Inquiry"); 561 | gotoxy(49, 10); 562 | printf("[2] . Cash Deposit"); 563 | gotoxy(49, 11); 564 | printf("[3] . Cash Withdrawal"); 565 | if (m == 1) { 566 | gotoxy(49, 12); 567 | printf("[4] . Main Menu"); 568 | } else { 569 | gotoxy(49, 12); 570 | printf("[4] . Exit"); 571 | } 572 | gotoxy(45, 17); 573 | printf("Please Enter Your Choice [1-4] : "); 574 | int a; 575 | scanf("%d", &a); 576 | switch (a) { 577 | case 1: 578 | system("cls"); 579 | chkblnc(); 580 | break; 581 | case 2: 582 | system("cls"); 583 | deposit(); 584 | break; 585 | case 3: 586 | system("cls"); 587 | withdrawl(); 588 | break; 589 | case 4: 590 | if (m == 1) 591 | menu(); 592 | else 593 | menuexit(); 594 | break; 595 | default: 596 | transaction(); 597 | } 598 | } 599 | 600 | // module for checking account balance and displaying it 601 | void chkblnc() { 602 | FILE *f; 603 | int a; 604 | gotoxy(48, 4); 605 | printf(" BALANCE INQUIRY "); 606 | gotoxy(47, 12); 607 | printf("Enter Your Account Number : "); 608 | scanf("%d", &a); 609 | if (chkacc(a) == 1) { 610 | f = fopen("record.bin", "rb"); 611 | while (fread(&rec, sizeof(rec), 1, f)) { 612 | if (rec.account == a) { 613 | gotoxy(50, 15); 614 | printf("Your Balance is : $%.2lf", rec.blnc); 615 | } 616 | } 617 | fclose(f); 618 | } 619 | if (chkacc(a) == 0) { 620 | system("cls"); 621 | gotoxy(52, 15); 622 | printf("Account Doesn't Exist."); 623 | chkblnc(); 624 | } 625 | gotoxy(46, 21); 626 | printf("Press any key to return back to main menu. "); 627 | getch(); 628 | transaction(); 629 | } 630 | 631 | // module for adding amount to a account 632 | void deposit() { 633 | int a; 634 | double b; 635 | FILE *x, *y; 636 | gotoxy(54, 4); 637 | printf(" CASH DEPOSIT "); 638 | gotoxy(47, 10); 639 | printf("Enter Your Account Number : "); 640 | scanf("%d", &a); 641 | if (chkacc(a) == 1) { 642 | x = fopen("record.bin", "rb"); 643 | y = fopen("new.bin", "wb"); 644 | while (fread(&rec, sizeof(rec), 1, x)) { 645 | if (rec.account != a) 646 | fwrite(&rec, sizeof(rec), 1, y); 647 | else if (rec.account == a) { 648 | rec.name; 649 | rec.account; 650 | rec.phone; 651 | rec.address; 652 | rec.email; 653 | rec.citiz; 654 | gotoxy(45, 13); 655 | printf("Enter The Amount To Deposit : $ "); 656 | scanf("%lf", &b); 657 | rec.blnc += b; 658 | fwrite(&rec, sizeof(rec), 1, y); 659 | } 660 | } 661 | fclose(x); 662 | fclose(y); 663 | x = fopen("record.bin", "wb"); 664 | y = fopen("new.bin", "rb"); 665 | while (fread(&rec, sizeof(rec), 1, y)) 666 | fwrite(&rec, sizeof(rec), 1, x); 667 | fclose(x); 668 | fclose(y); 669 | } 670 | if (chkacc(a) == 0) { 671 | system("CLS"); 672 | gotoxy(52, 21); 673 | printf("Account Doesn't Exist. "); 674 | gotoxy(41, 22); 675 | deposit(); 676 | } 677 | gotoxy(52, 21); 678 | printf("CASH DEPOSIT SUCCESSFULL"); 679 | gotoxy(50, 24); 680 | printf("Press any key to return back..."); 681 | getch(); 682 | transaction(); 683 | } 684 | 685 | // module to withdraw amount from account 686 | void withdrawl() { 687 | FILE *x, *y; 688 | int a; 689 | double b, z; 690 | gotoxy(54, 4); 691 | printf(" CASH WITHDRAWAL "); 692 | gotoxy(45, 10); 693 | printf("Enter Your Account Number : "); 694 | scanf("%d", &a); 695 | if (chkacc(a) == 1) { 696 | x = fopen("record.bin", "rb"); 697 | y = fopen("new.bin", "wb"); 698 | gotoxy(42, 13); 699 | printf("Enter The Amount To Withdraw : $ "); 700 | scanf("%lf", &b); 701 | while (fread(&rec, sizeof(rec), 1, x)) { 702 | if (rec.account != a) 703 | fwrite(&rec, sizeof(rec), 1, y); 704 | else if (rec.account == a) { 705 | rec.name; 706 | rec.account; 707 | rec.phone; 708 | rec.address; 709 | rec.email; 710 | rec.citiz; 711 | z = rec.blnc; 712 | if (b <= rec.blnc) { 713 | rec.blnc -= b; 714 | gotoxy(44, 21); 715 | printf(" CASH WITHDRAWAL SUCCESSFULL "); 716 | } 717 | fwrite(&rec, sizeof(rec), 1, y); 718 | } 719 | } 720 | fclose(x); 721 | fclose(y); 722 | remove("record.bin"); 723 | rename("new.bin", "record.bin"); 724 | if (z < b) { 725 | system("CLS"); 726 | gotoxy(48, 21); 727 | printf("Current Balance is $%.2lf", z); 728 | gotoxy(42, 24); 729 | printf("Entered amount exceeds current balance"); 730 | withdrawl(); 731 | } 732 | } 733 | if (chkacc(a) == 0) { 734 | system("CLS"); 735 | gotoxy(50, 21); 736 | printf("Account Doesn't Exist."); 737 | gotoxy(39, 22); 738 | withdrawl(); 739 | } 740 | gotoxy(42, 24); 741 | printf(" Press Any Key To Continue .... "); 742 | getch(); 743 | transaction(); 744 | } 745 | 746 | //module for logging out of the program. 747 | void menuexit() { 748 | system("cls"); 749 | gotoxy(48, 10); 750 | printf("!!! THANK YOU !!!"); 751 | gotoxy(50, 12); 752 | printf("USER :: %s", id); 753 | getch(); 754 | gotoxy(0, 26); 755 | exit(0); 756 | } 757 | 758 | void about() { 759 | gotoxy(48,10); 760 | printf("!!!ABOUT US!!!"); 761 | gotoxy(32,12); 762 | printf("This project has been created by Aman Khadka."); 763 | gotoxy(10,13); 764 | printf("It is a Simple Bank Management System Project for my 1st Semester based on C programming language."); 765 | gotoxy(40, 22); 766 | printf("Press any key to return back to main menu. "); 767 | char z = getch(); 768 | if (z == 13) { 769 | menu(); 770 | } 771 | } 772 | --------------------------------------------------------------------------------