Return array in a function

后端 未结 19 2834
清酒与你
清酒与你 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:01

    the Simplest way to do this ,is to return it by reference , even if you don't write the '&' symbol , it is automatically returned by reference

         void fillarr(int arr[5])
      {
           for(...);
    
      }
    

提交回复
热议问题