-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray.c
40 lines (34 loc) · 997 Bytes
/
array.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*****************************************************************//**
* \file array.c
* \brief gcc -c array.c -o array.exe -Wall
*
* \author Xuhua Huang
* \date November 2022
*********************************************************************/
#include <stdio.h>
#include <stdlib.h>
void displayArray(int arr[], const int size) {
for (int i = 0; i < size; i++) {
printf("%d, ", arr[i]);
}
printf("\n");
return;
}
// the displayArray function defined above
// is the same as the one defined below
// int arr[] will decade to int* arr
// void displayArray(int* arr, const int size) {
// for (int i = 0; i < size; i++) {
// printf("%d, ", *(arr+i));
// }
// printf("\n");
// return;
// }
int main(void) {
int vector[5] = { 1, 2, 3, 4, 5 };
displayArray(vector, 5);
printf("With dynamic array size determination:\n");
displayArray(vector, sizeof(vector)/sizeof(vector[0]));
system("pause");
return EXIT_SUCCESS;
}