i have to build a bank database in c for my end of year assignment but i cant fix the errors. Can someone please help .much appreciated
insert
Code:
#include<conio.h>
#include<stdio.h>
#include<string.h>
#define SIZE 100
/*definitions for the structures*/
struct date
{
int day;
int month;
int year;
};
typedef struct date DATE;
struct address
{
char town[50];
char street[50];
char county[50];
};
typedef struct address ADDRESS;
struct details
{
int number;
char first_name[];
char surname [];
ADDRESS address;
int age;
DATE DOB;
int balance;
};
typedef struct details DETAILS;
/*prototypes for fucntions*/
void add_an_account(DETAILS []);
void remove_an_account(DETAILS []);
void edit_account(DETAILS []);
void diplay_an_account(DETAILS []);
void display_account_details(DETAILS *);
void overdraft(DETAILS []);
void lodge_money(DETAILS []);
void withdraw(DETAILS []);
void init_database(DETAILS []);
void search_database(DETAILS []);
int menu(void);
void main()
{
DETAILS account[SIZE];
int menu_choice;
init_database(account);
printf("\n\nSelect from the menu\n1: add a new account\n"
"2: delete an account\n"
"3: display an account\n");
do
{
menu_choice = menu();
switch(menu_choice)
{
case 1 : add_an_account(account);
break;
case 2 : remove_an_account(account);
break;
case 3 : edit_account(account);
break;
case 4 : display_an_account(account);
break;
case 5 : display_account_details(account);
}
}
while (menu_choice !=0);
}
/*add an employee function*/
void add_an_account(DETAILS bank_account[])
{
int i=0;
while(bank_account[i].number!=0 && i < SIZE)
i++;
if ( i== SIZE)
printf("/n The database is full, please delete an account to add a new one /n");
else
{
printf("\n\n Enter your desired account number between 1 and 100 : ");
do
scanf("%d", &bank_account[i].number);
while(bank_account[i].number <=0 );
/* name of the new account */
printf("\n please enter your first name : ");
scanf("%s", &bank_account[i].first_name);
printf("\n please enter your surname : ");
scanf("%s", &bank_account[i].surname);
/*date of birth for the new account*/
printf("\n please enter your birth date\n");
printf("\n Day: (Max 2 digits) : ");
scanf("%2d", &bank_account[i].DOB.day);
printf("\n Month: (Max 2 digits) : ");
scanf("%2d", &bank_account[i].DOB.month);
printf("\n Year: (Max 2 digits) : ");
scanf("%2d", &bank_account[i].DOB.year);
/*the address of the new account*/
printf("\n please enter your address\n");
printf("\n Town: ");
scanf("%s", &bank_account[i].address.town);
printf("\n Street: ");
scanf("%s", &bank_account[i].address.street);
printf("\n county: ");
scanf("%s", &bank_account[i].address.county);
/* the balance of the new account*/
printf("\n please enter your starting balance \n");
scanf("%d", &bank_account[i].balance);
}
}
/*delete an account*/
/* deleting an account is done by replacing the account with a 0 in the array*/
void remove_an_account(DETAILS bank_account[])
{
int account_number;
int pos;
printf("\nEnter account that you want to be removed(1-100): ");
do
scanf("%d", &account_number);
while ( account_number >=1 );
pos = search_database(bank_account, account_number);
if( pos == SIZE)
printf("\nThis account is not in the database\n");
else
{
printf("\naccount %d deleted", account_number);
bank_account[pos].number = 0);
}
}
/*display a bank account*/
void display_an_account( DETAILS bank_account[] )
{
int account_number;
int pos;
printf("\nEnter account number desired(1 - 100): ");
do
scanf("%d", &account_number;);
while(account_number >=1)
pos = search_database( bank_account, DETAILS.number);
if(pos == SIZE)
printf("This account is not in the database\n")
else
display_account_details( &bank_account[pos]);
}
/*edit an accounts details*/
/*to edit the account you have to find the position of the account in the memory and change it*/
void edit_account(DETAILS bank_account[])
{
int account_number;
int pos;
printf("\nEnter the account number you wish to edit: ")
do
scanf("%d", &account_number);
while(account_number <=0 || account_number > SIZE)
pos = deletion_search(customer, account_number);
if(pos=SIZE)
printf("\nThere is no account with this number\n");
else
{
/*Replace the account holders first name*/
printf("\nPlease enter the new first name desired: ");
scanf("%s", DETAILS[pos].first_name);
printf("\nPlease enter the new surname desired: ");
scanf("%s", DETAILS[pos].surname);
/*change the date of birth details*/
printf("\nPlease enter the new date of birth desired: ");
printf(" Day: \n");
scanf("%d", DETAILS[pos].DOB.day);
printf(" Month: \n");
scanf("%d", DETAILS[pos].DOB.month);
printf(" Year: \n");
scanf("%d", DETAILS[pos].DOB.year);
/* change the address details*/
printf("\nPlease enter the new town desired: \n");
scanf("%s", DETAILS[pos].address.town);
printf("\nPlease enter the new street desired: \n");
scanf("%s", DETAILS[pos].address.street);
printf("\nPlease enter the new county desired: \n");
scanf("%s", DETAILS[pos].address.county);
}
}
/* search for an account*/
void search_database(DETAILS bank_account[], int emp_number)
{
int i = 0;
while(i<SIZE&&bank_account[i].number != emp_number)
i++;
return(i);
}
/* display an account */
void display_an_account(DETAILS bank_account[])
{
int account_no;
int pos;
/*find the account wanted*/
printf("\nPlease enter your account number(1-100): ");
do
{
scanf("%d", &account_no);
while(account_no >=0)
/*check to see if the account is in the database*/
pos = search_database(bank_account,account_no);
if(pos == SIZE)
printf("\nThe account is not in the database");
else
display_account_details(&bank_account[pos]);
}
}
/*display the details of an account*/
void display_account_details(DETAILS *ptr)
{
printf("\n\n\n")
printf("Account number: %d\n", ptr->number);
printf("First name: %s\n", ptr->first_name);
printf("Surname: %s\n", ptr->surname);
printf("Age: %d\n", ptr->age);
printf("Date of birth: %d%d%d\n", ptr->dob.day, ptr->dob.month, ptr->dob.year);
printf("Address: %s\n",ptr->address);
}
/*initialise database*/
void init_database(DETAILS bank_account[])
{
int i;
for(i=0;i<SIZE;i++)
bank_account[i].number = 0;
}
/*menu function*/
int menu(void)
{
int choice;
/*display the menu to the user*/
printf("\n\n 1: Add an account\n");
printf("\n\n 2: delete an account\n");
printf("\n\n 3: Edit an account\n");
printf("\n\n 4: display an account\n");
printf("\n\n 5: display an accounts details\n");
do
{
scanf("%d", &choice);
fflush(stdin);
}
while (choice >=1 || <=5);
return(choice);
}
Error E2268 assignment3.c 77: Call to undefined function 'display_an_account' in function main()
Error E2108 assignment3.c 144: Improper use of typedef 'DETAILS' in function remove_an_account(details *)
Error E2227 assignment3.c 144: Extra parameter in call to search_database(details *) in function remove_an_account(details *)
Error E2109 assignment3.c 144: Not an allowed type in function remove_an_account(details *)
Warning W8013 assignment3.c 145: Possible use of 'pos' before definition in function remove_an_account(details *)
Error E2379 assignment3.c 150: Statement missing ; in function remove_an_account(details *)
Error E2121 assignment3.c 163: Function call missing ) in function display_an_account(details *)
Error E2308 assignment3.c 163: do statement must have while in function display_an_account(details *)
Warning W8013 assignment3.c 164: Possible use of 'account_number' before definition in function display_an_account(details *)
Error E2108 assignment3.c 165: Improper use of typedef 'DETAILS' in function display_an_account(details *)
Error E2227 assignment3.c 165: Extra parameter in call to search_database(details *) in function display_an_account(details *)
Error E2109 assignment3.c 165: Not an allowed type in function display_an_account(details *)
Warning W8013 assignment3.c 167: Possible use of 'pos' before definition in function display_an_account(details *)
Error E2379 assignment3.c 169: Statement missing ; in function display_an_account(details *)
Warning W8057 assignment3.c 171: Parameter 'bank_account' is never used in function display_an_account(details *)
Error E2379 assignment3.c 182: Statement missing ; in function edit_account(details *)
Warning W8013 assignment3.c 184: Possible use of 'account_number' before definition in function edit_account(details *)
Error E2268 assignment3.c 185: Call to undefined function 'deletion_search' in function edit_account(details *)
Error E2451 assignment3.c 185: Undefined symbol 'customer' in function edit_account(details *)
Warning W8060 assignment3.c 186: Possibly incorrect assignment in function edit_account(details *)
Error E2108 assignment3.c 194: Improper use of typedef 'DETAILS' in function edit_account(details *)
Error E2108 assignment3.c 196: Improper use of typedef 'DETAILS' in function edit_account(details *)
Error E2108 assignment3.c 203: Improper use of typedef 'DETAILS' in function edit_account(details *)
Error E2108 assignment3.c 205: Improper use of typedef 'DETAILS' in function edit_account(details *)
Error E2108 assignment3.c 207: Improper use of typedef 'DETAILS' in function edit_account(details *)
Error E2108 assignment3.c 213: Improper use of typedef 'DETAILS' in function edit_account(details *)
Error E2108 assignment3.c 215: Improper use of typedef 'DETAILS' in function edit_account(details *)
Error E2108 assignment3.c 217: Improper use of typedef 'DETAILS' in function edit_account(details *)
Warning W8004 assignment3.c 219: 'pos' is assigned a value that is never used in function edit_account(details *)
Warning W8057 assignment3.c 219: Parameter 'bank_account' is never used in function edit_account(details *)
Error E2467 assignment3.c 229: 'search_database(details *,int)' cannot return a value in function search_database(details *,int)
Error E2171 assignment3.c 235: Body has already been defined for function 'display_an_account(details *)'
Error E2108 assignment3.c 246: Improper use of typedef 'DETAILS' in function display_an_account(details *)
Error E2228 assignment3.c 246: Too many error or warning messages in function display_an_account(details *)
*** 26 errors in Compile ***
>Exit code: 1
>bcc32 -v- -w -O1 assignment3.c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland