Project Code June 27
Project Code June 27
h>
#include<conio.h>
#include<string.h>
void welcomescreen();//function declaration
void login();
void mainmenu();
void addcustomer();
char user[20]="KARNA", pass[20]="1234";
struct customer{
char cname[15];
// char baddress[15];
// char cadd[15];
int accno;
float balance;
}c;
FILE *fptr;
void main()
{
fptr=fopen("customer.txt","r+");
if(fptr==NULL)
{
printf("File cannot open");
exit(0);
}
welcomescreen();// function call
login();
// mainmenu();
void login()
{
char username[20],password[20],ch;
int i;
system("cls");
printf("Enter you id:");
scanf("%s",&username);
printf("Enter your password:");
for(i=0;i<20;i++)
{
ch=getch();
if(ch==13)
{
break;
}
password[i]=ch;
printf("*");
}
password[i]='\0';
if(strcmp(user,username)==0 && strcmp(pass,password)==0)
{
mainmenu();
}
else
{
printf("Id password not matched, press any key to try again");
ch=getch();
login();
void mainmenu()
{ int choice;
char ch;
system("cls");
printf("Menu For Bank Management System\n");
printf("1. Add Customer \n2.Show Customer \n3.Deposit Amount \n4.Withdraw
Amount\n5.Exit");
printf("\nEnter the choice for above:");
scanf("%d",&choice);
switch(choice)
{
case 1:
addcustomer();
break;
case 2:
printf("Name:%s\nAccount No:%d\n
Balance:%f",c.cname,c.accno,c.balance);
break;
case 3:
printf("Add customer");
break;
case 4:
printf("Add customer");
break;
case 5:
exit(0);
default:
printf("\nInvalid choice wish to continue? Y|N");
fflush(stdin);
ch=getchar();
if(ch=='Y')
{
mainmenu();
}
else
{
exit(0);
}
}
}
void addcustomer()
{
system("cls");
printf("Enter record of customer");
printf("\nEnter name of customer");
scanf("%s",&c.cname);
printf("Enter the account number:");
scanf("%d",&c.accno);
printf("Enter the opening balance:");
scanf("%f",&c.balance);
fseek(fptr,0,2); //file ko pointer lai last ma lageko , 0 is offset, 2 indicates
last of file
fwrite(&c,sizeof(c),1,fptr);
printf("Record inserted successfully");
printf("Press any key to continue");
getch();
mainmenu();
}