Reputation: 123
While declairing functions and then describing it later is it ok to change the function parameters ?? I generally describe a function just after declaring it :
int function(int parameter_1 . int parameter_2)
{
Some Code..........
}
But in Programming in C by Brian Kernighnan I have a structure like :
int function(int parameter_1 , int parameter_2) //Only Declaring
main()
{
Some Code................
}
int function(int parameter_3 , int parameter_4) //Parameters Changed, type preserved
{
Some Code Here........
}
I get that the structure is right, but is it ok to change the parameters (even when the type is preserved) ??
(I don't believe it is a typo because the author changes parameter in every example he declares a function......)
Upvotes: 1
Views: 171
Reputation: 75545
As ooga mentioned in his comment, only the types and their order matter for declarations.
Upvotes: 1
Reputation: 23793
Parameters names are not part of functions signatures in C, you can change them between the definition and the declaration. It the Author does that, he is correct even if it is clearly discouraged.
However, changing the type changes the signature of the function, and would be incorrect.
Upvotes: 3