函数传递一维数组

#include <iostream>
void fun(int* a, int num)
{
    for (int i = 0; i < num; ++i)
    {
        std::cout << a[i] << " ";
    }
}

int main()
{
    int a[5] = {0, 1, 2, 3, 4};
    fun(a, 5);//数组名弱化为指针
    return 0;
}

 

posted @ 2016-10-07 21:24  zzyoucan  阅读(374)  评论(0编辑  收藏  举报