Default parameters in C
There are no default parameters in C.
One way you can get by this is to pass in NULL pointers and then set the values to the default if NULL is passed. This is dangerous though so I wouldn't recommend it unless you really need default parameters.
Example
function ( char *path)
{
FILE *outHandle;
if (path==NULL){
outHandle=fopen("DummyFile","w");
}else
{
outHandle=fopen(path,"w");
}
}
It is not possible in standard C. One alternative is to encode the parameters into the function name, like e.g.
void display(int a){
display_with_b(a, 10);
}
void display_with_b(int a, int b){
//do something
}
Not that way...
You could use an int array or a varargs and fill in missing data within your function. You lose compile time checks though.
Default parameters is a C++ feature.
C has no default parameters.