user1558619
user1558619

Reputation: 21

Default values for arguments in C

Say I have a function in C defined as :

bool check ( int x, int y);

Now if I call it using check(4);

What will be the value of y that is taken?

Upvotes: 2

Views: 422

Answers (1)

AnT stands with Russia
AnT stands with Russia

Reputation: 320371

Code like this can possibly compile only if the function is either undeclared (C89/90) or declared without a prototype (C89/90 and C99).

In any case the behavior will be undefined. If the number and/or type of promoted arguments used in the call do not match those used in the function definition, the behavior is undefined.

6.5.2.2 Function calls

6 [...] If the number of arguments does not equal the number of parameters, the behavior is undefined [...] If the function is defined with a type that does not include a prototype, and the types of the arguments after promotion are not compatible with those of the parameters after promotion, the behavior is undefined

Upvotes: 7

Related Questions