Variadic functions and arguments assignment in C/C++
- by Rizo
I was wondering if in C/C++ language it is possible to pass arguments to function in key-value form.
For example in python you can do:
def some_function(arg0 = "default_value", arg1):
# (...)
value1 = "passed_value"
some_function(arg1 = value1)
So the alternative code in C could look like this:
void some_function(char *arg0 = "default_value", char *arg1)
{
;
}
int main()
{
char *value1 = "passed_value";
some_function(arg1 = value1);
return(0);
}
So the arguments to use in some_function would be:
arg0 = "default_value"
arg1 = "passed_value"
Any ideas?