Find the answer to your Linux question:
Results 1 to 2 of 2
Hello guys, I have this problem.. I need to make a program (in C) that will do this: We have "trans.txt" file, it is a list of: Account1 Account2 Number ...
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    12

    Program help (C)

    Hello guys,
    I have this problem..

    I need to make a program (in C) that will do this:

    We have "trans.txt" file, it is a list of:
    Account1 Account2 Number
    this is one line, the file trans.txt might consist of many lines like this

    Account1 is account from which I want to transfer "money" to Account2,
    Number indicates how much "money" shall be transfered.

    Each account has own file..so account 1000 has it's info (amount of "money" left on the account) in "1000.txt" file etc.

    The transfer will only be done if there is sufficent amount of "money" in Account1.

    The thing is, it must be done in parallel. That means main proccess trans need to create one "child" for one transaction (3 transactions = 3 "childs").

    When done, the edited trans.txt file must look like:
    Account1 Account2 Number Result(ok or failed)

    So when input is like this:
    Code:
    $ cat 1000
    0.00
    $ cat 1001
    100.00
    $ cat 1002
    4.00
    $ cat trans
    1002 1000 5.00
    1001 1000 20.00
    1001 1002 60.00
    There can be 2 results (because it's done in parallel):
    Code:
    $ cat trans
    1002 1000 5.00 failed
    1001 1000 20.00 ok
    1001 1002 60.00 ok
    $ cat 1000
    20.00
    $ cat 1001
    20.00
    $ cat 1002
    64.00
    
    $ cat trans
    1002 1000 5.00 ok
    1001 1000 20.00 ok
    1001 1002 60.00 ok
    $ cat 1000
    25.00
    $ cat 1001
    20.00
    $ cat 1002
    59.00
    Any help would be greatly appreciated!
    Thanks in advance!

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    I assume that you're not actually asking us to do the work for you.

    Why don't you post the code you already have and then tell us why it doesn't do what you want?
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

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