Liste des Groupes | Revenir à cl c |
bart <bc@freeuk.com> writes:The end result is that a parameter declared with value-array syntax is passed using a reference rather than by value.
Arrays are passed by reference:This is the sort of thing that bad tutors say to students so that they
>
void F(int a[20]) {}
>
int main(void) {
int x[20];
F(x);
}
never learn C properly. All parameter passing in C is by value. All of
it. You just have to know (a) what the syntax means and (b) what values
get passed.
void F(int a[20]) ... declares a to be of type int *. Feel free to railAnd that is different 'int*' how, about from having an extra space which C says is not signigicant in this context?
about that as much as you like but that is what that syntax means.
The x in F(x) is converted to a pointer to x[0] since the x is not an
operand of &, sizeof etc. F(x) passes a pointer by value. F receives a
pointer value in a.
Although the type of 'a' inside 'F' will be int* rather thanNo. a is of type int *.
int(*)[20].
Les messages affichés proviennent d'usenet.