Find the answer to your Linux question:
Results 1 to 4 of 4
Hello all, I have the following : main () { int returncode ; [snip] retval = TransHist_Create( merchant_id, &trans_hist_id, transact_id, from_step_id, num_proc, num_succ, num_fail, num_user_err, todays_date, proc_user_id, addendum, getlocalhost(), getpid(), ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2009
    Posts
    33

    Function call good :) ReturnCode Bad :(


    Hello all,

    I have the following :

    main ()
    {
    int returncode;

    [snip]

    retval = TransHist_Create( merchant_id, &trans_hist_id, transact_id, from_step_id, num_proc, num_succ, num_fail, num_user_err, todays_date, proc_user_id, addendum, getlocalhost(), getpid(), 0, __FILE__, __LINE__, &returncode);

    }

    Now, in the function : TransHist_Create(...., *returncode)
    {
    ....... [snip] ...

    *returncode = 0;
    return 0;

    }


    BUT ..

    in main, the returncode is set to --> 1 <-- ?!?!

    Why??

    TIA

  2. #2
    Just Joined!
    Join Date
    Jun 2009
    Posts
    33
    Hello again,

    I read this here:
    Call by Value and Call by Reference

    But i guess i am still missing something ..

    Can someone please tell me how to pass a value to a function in such a way that a function can change it?

    -> I want to pass in a value called: returncode
    -> Have the function change it
    -> and then review it from the calling program.

    How can this be done?

    TIA

  3. #3
    Just Joined!
    Join Date
    Jun 2009
    Posts
    33
    PS - the reason why I am not doing it as :

    return_code = Function()

    is because I have been burned on this. The return code in the function is 0 but the value returned is <> 0.

    So, I was trying something else ...

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,530
    You only posted a snippet of your function call arguments and the actual signature of the function itself. Please post in detail. As someone once said, there be the Devil (in the details)...
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

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