Suggestion for Account record

This is a discussion on Suggestion for Account record within the C++ Programming forums, part of the General Programming Boards category; Hi all,, A module of my Bank Management System which should display the user account details after successfuly entering his/her ...

  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    158

    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面
    Last edited by jeedi khan; 01-28-2014 at 03:13 AM.

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,537
    Quote Originally Posted by jeedi khan View Post
    1.How should i achieve human readable data format ?
    One option is to use the stream operator >> and <<. They write everything to files as strings by default, so they are human readable.
    If you need something more sophisticated, I suggest you look into XML, JSON or YAML.

    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.
    There is. MySQL has a C API for interacting with it. Furthermore, there are C++ wrappers that allows you to interact with it, as well. You should study the API to figure out how to do it.

    Furthermore, you really should indent your code.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. close account?
    By Lauren Nicole in forum Tech Board
    Replies: 11
    Last Post: 04-07-2013, 03:42 PM
  2. Want to delete my account
    By Freikorp in forum General Discussions
    Replies: 1
    Last Post: 05-28-2011, 08:21 AM
  3. Update Record & Delete Record in File.
    By unsafe_pilot1 in forum C Programming
    Replies: 13
    Last Post: 05-18-2008, 07:22 AM
  4. Bank Account
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 09-14-2003, 02:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21