I am trying to learn C and am very confused already.

In the OOP languages i have used there exists the ability to perform method overloading, where the same function could have different parameter types and call whichever was the most appropriate.

Now in C i know that this is not the case so i cant figure out the following problem, How printf() works.

For example:

char chVar = 'A';
int intVar = 123;
float flVar = 99.999;

printf("%c - %i - %f \n",chVar, intVar, flVar);
printf("%i - %f - %c \n",intVar, flVar, chVar);
printf("%f - %c - %i \n",flVar, chVar, intVar);

Now as C does'nt support function overloading, How does printf manage to take any number of arguments, of any type, and then work correctly with them?

I have tried to find the printf() working by downloading the glibc source package but can quite seem to find it, though i'll keep looking.

Could anyone here explain how C performs the above task?

Edit
Report