#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    4
    Rep Power
    0

    Question traverse a linked list


    Hi Everyone

    I'm just just learning C++ at the moment and I was wondering if any of you could point me in the right direction to say, add transaction information to an account number, and then traverse the list of transactions that belong to that account? Does anybody have any examples please.

    Thx
    Darren
  2. #2
  3. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    Most people would store this info in a database. Storing it in structures in a program is not reliable (how easy is it to keep your books strait if your computer crashes and all the last three weeks of account information just dissapeared?). Are you sure this isn't homework?

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    4
    Rep Power
    0
    Yes, this is an assignment. Once all of the above mentioned is carried out, then there would be a save method, which saves all listed, etc to a txt file.

    Any help on the adding a list of transactions to an account, and then traverse it.....please.

    Ps: this does not use odbc or any other type of data connection. Just a read from txt file.
  6. #4
  7. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    If you are using C++, look into the use of a vector and/or a map to store classes with your data. For I/O look into fstream. In C you create structures and for I/O use FILE variables. You could store the data in a linked list or simply an array that you keep reallocating.

    What you are asking is somewhat complicated and this forum is for helping you with bugs or specific issues, not doing the work for you.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  8. #5
  9. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1511
    Assuming you've already found the right account, you'd traverse a list doing something like this:
    Code:
    transaction *cur=account.firsttransaction;
    while (cur != NULL) {cur = cur->Next;}
    The names will vary with implementation, and it's up to you to figure out what to do at each stop.
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn

IMN logo majestic logo threadwatch logo seochat tools logo