How do i pass an array function without using pointers

前端 未结 7 886
广开言路
广开言路 2021-02-05 21:04

I have been asked in an interview how do you pass an array to a function without using any pointers but it seems to be impossible or there is way to do this?

7条回答
  •  一个人的身影
    2021-02-05 21:36

    simply pass the location of base element and then accept it as 'int a[]'. Here's an example:-

        main()
        {
            int a[]={0,1,2,3,4,5,6,7,8,9};
            display(a);
        }
        display(int a[])
        {
            int i;
            for(i=0;i<10;i++) printf("%d ",a[i]);
        }
    

提交回复
热议问题