Liste des Groupes | Revenir à cl c |
bart <bc@freeuk.com> writes:Little about C's type system is simple. You're doing your students a disservice if you try and hide all the quirks.
On 09/07/2024 16:58, Ben Bacarisse wrote:An address value is passed by value. C has only one parameter passingbart <bc@freeuk.com> writes:>
>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.
The end result is that a parameter declared with value-array syntax is
passed using a reference rather than by value.
>
And it does so because the language says, not because the ABI requires
it. A 2-byte array is also passed by reference.
mechanism. You can spin it as much as you like, but C's parameter
passing is simple to understand, provided learner tune out voices like
yours.
Sorry, I missed what you wrote. I don't know why even brought up intint(*)[20] would be the type of 'a' inside my function, IF it was properly passed by value instead of some weird combination.
(*)[20] but I thought you were saying that was the type of a.
Les messages affichés proviennent d'usenet.