The parameter type
dataType a[ ] and
the parameter type
dataType *a in
C
- The parameter
int
a[ ] in a
C function
represents an
array as
parameter:
void f(int a[ ]) // a is the base address of an array of int variables
{
...
}
The parameter a contains the base address of an int typed array:
| |
+-------+
a: | 7000 |
+-------+
| ... |
| ... |
+-------+
7000 | int | <--- there is an int type array here
+-------+
| int |
+-------+
| int |
+-------+
| ... |
|
|
The parameter type
dataType a[ ] and
the parameter type
dataType *a in
C
- The parameter
int
*a in a
C function
represents an
reference variable as
parameter:
void f(int *a) // a is the address of int typed variable
{
...
}
The parameter a contains the address of an int typed variable:
| |
+-------+
a: | 7000 |
+-------+
| ... |
| ... |
+-------+
7000 | int | <--- there is an int type variable here
+-------+
| ??? |
+-------+
| ??? |
+-------+
| ... |
|
Notice:
there is
no difference
in the interpretation
of
int a[ ] and
int *a !!!
In both cases,
the parameter
a
contains the
address of
an
int typed
variable !!!
|
In C: the declaration
a[] and the declaration
*a are
equivalent
In C: the declaration
a[] and the declaration
*a are
equivalent
DEMO:
demo/C/set1/selectionSort2.c
❮
❯