parameter passing

This is a discussion on parameter passing within the C Programming forums, part of the General Programming Boards category; Another question. I have to calculate the weekly pay using two dimensional arrays. My teach emailed me back saying that ...

  1. #1
    Jax
    Jax is offline
    Registered User
    Join Date
    Nov 2001
    Posts
    5

    parameter passing

    Another question.
    I have to calculate the weekly pay using two dimensional arrays. My teach emailed me back saying that my parameters should say void calc_pay(int emp_counter, wg_hr_py[i][x])
    but when I write that part of the program it doesn't work
    This is exactly what I have.
    void calc_pay(int emp_counter, wg_hr_py[i][x])
    {
    int i;
    for(i = 0; i < emp_counter; i++)
    {
    wg_hr_py[i][2] = wg_hr_py[i][1] * wg_hr_py[i][0]
    }
    }
    Please help.


  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > My teach emailed me back saying that my parameters should
    > say void calc_pay(int emp_counter, wg_hr_py[i][x])

    What I believe they meant is: if your array is:

    int myarray[3][4];

    Then your function prototype should be:

    void calc_pay( int emp_counter, wg_hr_py[3][4] )

    Thus, it accepts a 3x4 array as a parameter, not to literally give it "i" and "x" parameters. Fire your teacher, he is not good at explaining things.

    Quzah.

  3. #3
    junior member mix0matt's Avatar
    Join Date
    Aug 2001
    Posts
    144
    you also need to type the array in the prototype and/or definition....

    void calc_pay (int emp_counter,double wg_hr_py [] [4]); // or whatever type the array is...
    THIS IS NOT JUST A CHRONICLING OF THINGS WE HAVE DONE IN THE PAST BUT OUR RISE TO POWER.

  4. #4
    Unregistered
    Guest

    Question

    Hi Jax, I have to learn about parameter passing as well.

    Could you post some code with a function using it, just a piece as little as possible, the simplest example you've got?

    Thanks in advance

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    207
    I'm the one who posted the last message, and this is the question I made already, if you want to have a look:

    http://www.cprogramming.com/cboard/s...6&goto=newpost

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. parameter passing and pointers
    By pokiepo in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 01:13 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  5. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM

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