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
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,262

    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. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center