Search code examples
cparametersdefault

Default parameters in C


Is it possible to set values for default parameters in C? For example:

void display(int a, int b=10){
//do something
}

main(){
  display(1);
  display(1,2); // override default value
}

Visual Studio 2008, complaints that there is a syntax error in -void display(int a, int b=10). If this is not legal in C, whats the alternative? Please let me know. Thanks.


Solution

  • Default parameters is a C++ feature.

    C has no default parameters.