Possible Duplicate:
How to modify content of the original variable which is passed by value?
I am building a
You intialize rArea to 0. Then, you pass it into FindArea by value. This means none of the changes to rArea in the function are reflected. You don't make use of the return value, either. Therefore, rArea stays 0.
Option 1 - Use the return value:
int FindArea(int rBase, int rHeight) {
return rBase * rHeight;
}
rArea = FindArea(rBase, rHeight);
Option 2 - Pass by reference:
void FindArea(int *rArea, int rBase, int rHeight) {
*rArea = rBase * rHeight;
}
FindArea(&rArea, rBase, rHeight);