This code doesn't work in C. Is there a way to have variable b take a default value of 2 in C?Code:#include <stdio.h> void func(int a, int b=2) { printf("%d",a+b); } int main() { func(1,1); func(1); return 0; }
Thanks!
This code doesn't work in C. Is there a way to have variable b take a default value of 2 in C?Code:#include <stdio.h> void func(int a, int b=2) { printf("%d",a+b); } int main() { func(1,1); func(1); return 0; }
Thanks!
No. Default arguments and function overloading are both specific to C++. There is no equivalent in C.