-
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.
:D
-
> 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.
-
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...
-
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
-
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