type of an array
Posted
by Tim
on Stack Overflow
See other posts from Stack Overflow
or by Tim
Published on 2010-01-09T21:41:52Z
Indexed on
2010/04/05
0:53 UTC
Read the original article
Hit count: 309
Hi, when I need to pass an array to a function, it seems all the following declarations of the function will work
void f(int arr[])
void f(int arr[4]) // is this one correct?
for this:
int a[]={1,2,3,4};
f(a);
But when I assign an array to another array, it fails
int a[]={1,2,3,4};
int b[4] = a; // error: array must be initialized with a brace-enclosed initializer
So why an array passed as an argument of a function is okay, but used on the rhs of simple assignment is wrong?
Thanks!
© Stack Overflow or respective owner