how sizeof() works in pass by reference arguments

后端 未结 6 1719
深忆病人
深忆病人 2021-01-22 04:56

I passed a array to function and tried to find the length of the array . but the result was not expected . can anybody explain please?

int main()
{
     int arra         


        
6条回答
  •  温柔的废话
    2021-01-22 05:52

    You are sending and recieving a array pionter, not the array.

    while sending arg::

    func(array[10]);
    

    While Receiving arg:

    void func(int array[10])
    

    But it's not good to send the total array. So send and receive arguments like below.

    func(array, arry_size);  //function call
    void func(int array[], int length)  //defin
    

提交回复
热议问题