C語言基礎:數組作為函數參數傳遞演示源碼
阿新 • • 發佈:2019-01-30
urn play 內容 arr splay val nts std elements 將做工程過程中常用的內容片段記錄起來,如下內容內容是關於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
C語言基礎:數組作為函數參數傳遞演示源碼