cLanguage can only pass a pointer, which is the first address of the array~
void a(int* array);
void b(int array[]);
When a function is declared, int* array and int array[] are equivalent, and array can only be a pointer. The first two are exactly the same and can also be written as:
void d(int const* array);
This is the same, the array is passed as a const pointer in c.
In the example below, you can see that arr points to the same address.
Although C cannot pass arrays as parameters, you can still create an "unnamed" array when passing parameters like this:
c
Language can only pass a pointer, which is the first address of the array~When a function is declared,
int* array
andint array[]
are equivalent, and array can only be a pointer.The first two are exactly the same and can also be written as:
This is the same, the array is passed as a const pointer in
c
.In the example below, you can see that arr points to the same address.
As for the example of @拉丝Master, I tried it in vs2010 and it showed a syntax error. Maybe, is there something I didn't do right?
Also, if you want to complain, there are no points for likes in comments. There is no need for the author to be stingy enough to even cancel this~ :D
The argv (argument vector) used by C programs to receive parameters by default is a string array.
char *argv[] = {"str1", "str2"};