void array_call_by_value (int arr[])
{
arr[0] = 2;
printf("[in] function\n");
printf("%d %d %d\n", arr[0], arr[1], arr[2]);
}
int main()
{
int arr[] = {1, 2, 3};
printf("[before] function\n");
printf("%d %d %d\n", arr[0], arr[1], arr[2]);
array_call_by_value(arr);
printf("[after] function\n");
printf("%d %d %d\n", arr[0], arr[1], arr[2]);
}
=====Result=====
1.array是沒有pass by value
2.return arry by value(編譯會錯誤!!)
ex:
int [] array_call_by_value (int arr[])
{
arr[0] = 2;
printf("in function\n");
printf("%d %d %d\n", arr[0], arr[1], arr[2]);
}
沒有留言:
張貼留言