I see C books that use the same variable names in the function definition, calling function and declaration. Others use the same variable names in the calling function and in the declaration/prototype but a different one in the definition as in:
void blabla(int someth开发者_如何学Going); //prototype
blabla(something) // calling function inside main after something has been initialized to int
void blabla(int something_else) //definition
I have two questions:
What convention is best to use in C?;
Does the convention apply regardless whether a value is being passed "by-value" or if it's being passed by a pointer?
Thanks a lot...
The name used for a function parameter in a function declaration is basically just a comment. It doesn't have any meaning and (as you've noticed) doesn't have to match the function definition. That said, it should be a good descriptive name that tells you what the parameter is for. So why not use the same name in the declaration? If you use a different name and one of the names is better (more descriptive), then you should probably use that name in both places.
精彩评论