The ints are passed into printf() as arguments. That means printf() has a
copy of the int.
You do one of two ways:
Here the 3,4,5 are copied as arguments. printf() just look in memory (the stack frame) for the three ints. There it will find the copies of the 3, 4 and 5.
Or you could:
-
int a = 3;
-
int b = 4;
-
int c = 5;
-
printf("%d%d%d", a,b,c);
-
In this case, the ints (a b c) have been copied to the printf() stack frame so this case is just like the previous one. Here are the copies of a,b and c.
What happens is the printf() function has this prototype:
-
size_t printf(const char*, ...);
-
The ellipsis argument (...) means and unspecified number of arguments. What printf() does is go through the first argument looking for % signs. The number of % signs tells printf() how many arguments are represented by the second argument (the ...). The code after each % (like %d) tells print() how big that argument is. With this information, printf() makes a calculation of the address where the argument should be in the stack frame. Then it just displays what is there.
Of course, if you never provided the second argument, the calculation arrives at some location in memory and you are just shown the contents of that memory.
You can read up on the vararg macros if you want to. These are the ones that do that calculating of memory addresses for the ellipsis argument.