Return array in a function

后端 未结 19 2290
清酒与你
清酒与你 2020-11-22 05:23

I have an array int arr[5] that is passed to a function fillarr(int arr[]):

int fillarr(int arr[])
{
    for(...);
    return arr;
         


        
19条回答
  •  伪装坚强ぢ
    2020-11-22 06:08

    int *fillarr(int arr[])
    

    You can still use the result like

    int *returned_array = fillarr(some_other_array);
    if(returned_array[0] == 3)
        do_important_cool_stuff();
    

提交回复
热议问题