Magcialking posted:
for example,in the function "int a(int[] b)", I wanna every element
of array b to be dealt with, but b's length remains unkown, so what
can I do?
The following two functions are exactly equivalent:
void Func(int arr[]) {}
void Func(int *arr) {}
You cannot pass an array by value to a function. If you write a
function signature with a parameter such as arr[], you're really just
taking a pointer by value.
If you want your function to be able to take an array (and to know its
length), then start off with a function such as the following:
void Func_BehindTheCurtains(int *p,size_t len) {}
, and then invoke it using the following:
template<size_t len>
void Func(int (&arr)[len])
{
return Func_BehindTheCurtains(arr,len);
}
Now you can invoke it as follows:
int main()
{
int arr[43];
Func(arr);
}