How to pass an Array to function by Value ?
Syntax-wise, strictly speaking you cannot pass an array by value to function in C.
void func (int* x); /* this is a pointer */
void func (int x[]); /* this is a pointer */
void func (int x[10]); /* this is a pointer */
However, for the record there is a dirty trick in C that does allow you to pass an array to function by value in C. Don't try this at home! Because despite this trick, there is still never a reason to pass an array by value.
typedef struct
{
int my_array[10];
} Array_by_val;
void func (Array_by_val x);
Please like this video and subscribe to my channel for more programming interview videos.
~-~~-~~~-~~-~
Please watch: "Friend Function and Friend Class in C++ || Programming Interview Questions"
• Friend Function and Friend Class in C...
~-~~-~~~-~~-~