您的位置:首页 > 编程语言 > C语言/C++

C语言基础:数组作为函数参数传递演示源码

2019-01-30 15:59 501 查看

将做工程过程中常用的内容片段记录起来,如下内容内容是关于C语言基础:数组作为函数参数传递演示的内容,应该能对小伙伴也有好处。

#include <stdio.h>

void show_array(int values[], int number_of_elements)
{
int i;

printf("About to display %d valuesn", number_of_elements);
for (i = 0; i < number_of_elements; i++)
printf("%dn", values[i]);
}

int main(void)
{
int scores[5] = {70, 80, 90, 100, 90};
int count[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int small[2] = {-33, -44};

show_array(scores, 5);
show_array(count, 10);
show_array(small, 2);

return 1;
}

输出结果

About to display 5 values
70
80
90
100
90
About to display 10 values
1
2
3
4
5
6
7
8
9
10
About to display 2 values
-33
-44
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  函数传递 数组