Suggestion for Account record
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Suggestion for Account record

  1. #1
    Join Date
    Jan 2014
    Posts
    3

    Post Suggestion for Account record

    Hi all,,

    A module of my Bank Management System which should display the user account details after successfuly entering his/her details calls to a function:
    Code:
    
    
    void display_acc(int n)
    {
    account acc;
    int flag=0;
    ifstream inFile;
    inFile.open("account.txt",ios::in);
    if(!inFile)
    {
    cout<<"File could not be open !! Press any Key...";
    return;
    }
    cout<<"\nBALANCE DETAILS\n";
    while(inFile.read((char *) &acc, sizeof(account)))
    {
    if(acc.ret_acno()==n)
    {
    acc.show_account();
    flag=1;
    }
    }
    inFile.close();
    if(flag==0)
    cout<<"\n\nAccount number does not exist";
    }
    where
    Code:
    void account::show_account()
    {
    cout<<"\nAccount No. : "<<acno;
    cout<<"\nAccount Holder Name : ";
    cout<<name;
    cout<<"\nType of Account : "<<type;
    cout<<"\nBalance amount : "<<&account::deposit;
    }
    and
    Code:
    int account::ret_acno()
    {
    return acno;
    }
    the name of my class is account which contains public functions declarations and other variables:
    But on run it says "File could not be open !! Press any Key..."



    What I wanna know is that my account.txt is a text file and contains data in unreadable format except the string values....
    1.How should i achieve human readable data format ?
    2.Is there any mechanism where i should connect my this C++ program to SQL database where i should create an account table and auto-increment it for users having each users required data and then retrieve on display_acc function i.e on write_acc should enter acc.no,acc.holder name etc and on demand should retrieve it from MYSQL database.
    Please ensure me to do so...

    account.txt contains data like despite of declaring it *.txt:
    面面面面面粍 C面 面面面面面未 C面 E javed 面面面面面 面面X S面

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    5,835

    Re: Suggestion for Account record

    Code:
    if(!inFile)
    {
    cout<<"File could not be open !! Press any Key...";
    return;
    }
    Have a look at the is_open() stream function.
    http://www.cplusplus.com/reference/f...tream/is_open/
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.4.4)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)