0
Changing the order of parameters while calling function in V
While i call the function in c,if i change the order od parameters like:- Int disp(int j,float a) { printf("%i\n%f",i,j); } Void main() { disp(2.0,1); } O/p:- 2 1.00000 //How can i use name parameter in c
3 Réponses
+ 2
"How can I use named parameter in C?"
We can't AFAIK. The closest thing to named parameters I could think of was `struct` initializer, where we can use the `struct` member's name to specify the members' values in arbitrary order.
Even partial `struct` members' values initialization was possible, but obviously, with the risk of getting undesired values assigned to it, or them.
struct A
{
int i;
float f;
};
// create and assign members' values
// in different ordering
struct A a = { f : 20.22, i : 2022 };
printf( "i = %d, f = %.2f\n", a.i, a.f );
But that was a whole different story ...
+ 1
Pass the values same order as in the function definition...
There you getting automatically casted values but may you get wrong result..
+ 1
ㅗ댝햐ㅓㅁ