The prototype of printf
and scanf
in stdio.h
are:
int scanf ( const char * format, ... );
int printf ( const char * format, ... );
Seems like it accepts the same type of argument, that is const char * format
. I understand that is a pointer to a constant char variable that has name "format". So both function accept format name as first variable. But the list of argument after ,...
make me confused.
Take 2 example, we will see printf
accept something like content of variable
Example:
int a = 20;
int *pa = &a;
printf("%d", a);
printf ("%d", *pa);
scanf()
accepts the address of variable:
Example:
int a =20;
int *pa = &a;
scanf("%d", &a);
scanf("%d", pa);
In short, it easy to accept that is the way these function work, but how I can find where they define, prototype in header file is not enough, I can try to google something like:"built a printf() for yourself", some books like "C programming language" also teach how to create some built-in function.
But I think there must have some file that saved all these functions.