How does Variable Length Argument lists functions like printf() , scanf(), etc in C differ from Function Overloading in C++?
And how does the call
printf("Didnt Work %s",s);
differ from
printf(s,"Didnt Work %s");
where s is defined as:
const char *s="string";
Please Explain.
In
The first argument “string” is interpreted as the format string. It has no insertion codes, so the second parameter won’t ever be used. The result will be “string”.
OTOH
There is an insertion code, so the second argument gets inserted as a string, the result is “Didn’t Work string”.
This isn’t overloading, because although different argument types are possible just as in overloading, with variable arguments the same function is always called. With overloading different functions are called depending on the argument types.