Why doesn't return modify the value of a parameter to a function

前端 未结 7 1056
盖世英雄少女心
盖世英雄少女心 2020-12-22 13:57

Possible Duplicate:
How to modify content of the original variable which is passed by value?

I am building a

7条回答
  •  伪装坚强ぢ
    2020-12-22 14:30

    take rArea by pointer:

    int FindArea(int *, int , int);
    
    ...
    
    FindArea (&rArea , rBase , rHeight);
    
    ...
    
    
    
    int FindArea (int *rArea , int rBase , int rHeight)
    {
     *rArea = (rBase * rHeight);
    
     return (*rArea);
    
    }
    

提交回复
热议问题