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

将做工程过程中常用的内容片段记录起来,如下内容内容是关于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

猜你喜欢

转载自blog.51cto.com/14137494/2347914