Thread: C end of year assignment(need to pass badly)

  1. #1
    Banned
    Join Date
    Apr 2011
    Posts
    19

    C end of year assignment(need to pass badly)

    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

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    So how many different places did you cobble this together from?

    Code:
    Error E2268 assignment3.c 77: Call to undefined function 'display_an_account' in function main()
    Take a look at these error messages...
    Each one tells you a line number (77 in the example above), what the problem is, and which function it happens in...

    Just work through each one until you get them all fixed.

  3. #3
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    Code:
     struct details
     {
         int number;
         char first_name[];
         char surname [];
         ADDRESS address;
         int age; 
         DATE DOB;
         int balance;
     };
    Give the array the number of elements.
    You don't want incomplete array here.

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    278
    Go through the errors one at a time starting at the first one.

    Error E2268 assignment3.c 77: Call to undefined function 'display_an_account' in function main()
    display_an_account is not prototyped. You may think it is, but a simple search will show you that it is not.
    Error E2108 assignment3.c 144: Improper use of typedef 'DETAILS' in function remove_an_account(details *)
    struct details needs sizes for the char array I think.
    Error E2227 assignment3.c 144: Extra parameter in call to search_database(details *) in function remove_an_account(details *)
    Pretty obvious. Prototype is: void search_database(DETAILS []) yet you define it and call it with two parameters.

  5. #5
    Banned
    Join Date
    Apr 2011
    Posts
    19

    Talking replys

    thanks lads i see what you guys mean but i still cant fix the errors at all.. does anyone of you care to help and just rewrite 1 or 2 of the errors for me it would be a great help and you would know that you helped me get into second year in college

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by morrissey999 View Post
    thanks lads i see what you guys mean but i still cant fix the errors at all.. does anyone of you care to help and just rewrite 1 or 2 of the errors for me it would be a great help and you would know that you helped me get into second year in college
    No we wouldn't know that... what we'd know is that we've helped you cheat on your final exam.

    Look, it's pretty simple... if you didn't bother to learn this in class, you should fail the test.

  7. #7
    Banned
    Join Date
    Apr 2011
    Posts
    19
    trust me im only asking cause you have no idea how ........e my lecturer is.. he never thought my class how to fix errors etc and i didnt miss a class

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > he never thought my class how to fix errors etc and i didnt miss a class
    Then you ALL deserve to fail, and he should be sacked.
    You would all be utterly useless in the workplace, so there's no point is there?

    Look at it this way, save yourself another year or two of going down the wrong road.

    Oh, and FWIW, read this
    A development process
    Dumping sorry messes of code on the forum for us to fix isn't going to work.

    Small steps, compiled often means you don't get swamped with errors.

    Another FWIW for the first error - learn how to spell.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Banned
    Join Date
    Apr 2011
    Posts
    19
    here what is your problem.. im only starting in college and im sorry if im not stephen hawking .im new to doing programming.. the point of these boards are to get help and learn not listen to some inconsiderate person like yourself going on just cause your better doesnt mean you can moan on at other people

  10. #10
    Banned
    Join Date
    Apr 2011
    Location
    Santry, Ireland
    Posts
    29
    Salem ur an awful C.U.N.T , in case u havnt copped on by now me and morrissey are in the same class, why should we deserve to fail if we have a bad lecturer and have tried numerous times to learn this ourself, i hope you die a slow painfull death on your own

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Salem View Post
    Dumping sorry messes of code on the forum for us to fix isn't going to work.
    Small steps, compiled often means you don't get swamped with errors.
    Another FWIW for the first error - learn how to spell.
    You might also notice a more than passing similarity to IrishFeeney's code... as well.

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by morrissey999 View Post
    here what is your problem.. im only starting in college and im sorry if im not stephen hawking .im new to doing programming.. the point of these boards are to get help and learn not listen to some inconsiderate person like yourself going on just cause your better doesnt mean you can moan on at other people
    DO YOU KNOW HOW TO READ?

    Each of the error messages you got has a line number and an explaination right in it.
    It's litterally telling you what's wrong with your code. All you need to do is Read and Fix...

    There is only one reason you can't do that... because you didn't write the code in the first place.
    If you had written it, you would know what's going on inside it and fixing errors would be childsplay.

  13. #13
    Banned
    Join Date
    Apr 2011
    Posts
    19
    yeah we have the same project to do but we literally were given this 2 days after we were thought stuctures etc and like our entire class is stuck as well.. im just wondering more than anything how to fix the errors

  14. #14
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by morrissey999 View Post
    yeah we have the same project to do but we literally were given this 2 days after we were thought stuctures etc and like our entire class is stuck as well.. im just wondering more than anything how to fix the errors
    Then you are trying to fix the WRONG errors... you need to go, as a class, to the dean or principal and DEMAND a professor who actually knows what he's doing.

    No you should not fail because you have a bad teacher... but promoting you to the next year isn't the right answer either, since it's plain obvious you haven't learned the necessary materials...

    Therefore your only workable solution is to get a new teacher and get caught up on the stuff he didn't cover...

    And, btw, don't wait around for that to happen... there are a ton of books, e-books, tutorials and other courseware you can climb into and catch up... as I told feeney... sitting around waiting for people to spoon feed you information is a total fools errand.

  15. #15
    Banned
    Join Date
    Apr 2011
    Posts
    19
    i dont expect anyone to feed me the answers but i cant relearn c in what i have covered by monday thats when its due

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pass be reference versus pass by value
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 08-01-2002, 01:03 PM
  2. I need help badly
    By taz_jiggy in forum C++ Programming
    Replies: 4
    Last Post: 04-23-2002, 09:36 PM
  3. Replies: 3
    Last Post: 04-02-2002, 01:39 PM
  4. Very badly need help!
    By Silverdream in forum C Programming
    Replies: 1
    Last Post: 02-13-2002, 09:13 PM
  5. need help badly...
    By Unregistered in forum C Programming
    Replies: 8
    Last Post: 02-09-2002, 10:46 PM