# Pass array value into function: by array, by empty array and by pointer : Function Parameters « Function « C / ANSI-C

Home
C / ANSI-C
 1 assert.h 2 Console 3 ctype.h 4 Data Structure Algorithm 5 Data Type 6 Development 7 File 8 Function 9 Language Basics 10 Macro Preprocessor 11 Math 12 math.h 13 Memory 14 Pointer 15 setjmp.h 16 signal.h 17 Small Application 18 stdio.h 19 stdlib.h 20 String 21 string.h 22 Structure 23 time.h 24 wctype.h
 C / ANSI-C » Function » Function Parameters Screenshots
Pass array value into function: by array, by empty array and by pointer
 #include  void f1(int num[5]), f2(int num[]), f3(int *num); int main(void) {   int count[5] = {1, 2, 3, 4, 5};   f1(count);   f2(count);   f3(count);   return 0; } /* parameter specified as array */ void f1(int num[5]) {   int i;   for( i = 0; i < 5; i++)        printf("%d ", num[ i ]); } /* parameter specified as unsized array */ void f2(int num[]) {   int i;   for( i = 0; i < 5; i++)        printf("%d ", num[ i ]); } /* parameter specified as pointer */ void f3(int *num) {   int i;   for(i = 0; i < 5; i++)        printf("%d ", num[ i ]); }
Related examples in the same category
 1 Calculating an average using variable argument lists 2 Computes the area of three triangles 3 Demonstrate the use of pointers and parameter passing 4 Pass value 5 Pass reference 6 A function to increase your salary 7 Pass array with different dimension into function 8 Pass Array into a function 9 Use function with pointer parameters 10 Define int pointer parameter for a function 11 Pass reference of an int value into function 12 Pass char pointer into function 13 Passing the data type addess into the function 14 Length of the function parameters 15 Return value though parameter 16 Pass return value through function parameter 17 Define constant function parameter 18 Char pointer as the function parameter 19 Passing parameter by pointer 20 Pass double value into function