What is the output of printf("%d")?
Answer Posted / arvind kumar yadav
When we use %d the compiler internally uses it to access
the argument in the stack (argument stack). Ideally
compiler determines the offset of the data variable
depending on the format specification string. Now when we
write printf("%d",a) then compiler first accesses the top
most element in the argument stack of the printf which is %
d and depending on the format string it calculated to
offset to the actual data variable in the memory which is
to be printed. Now when only %d will be present in the
printf then compiler will calculate the correct offset
(which will be the offset to access the integer variable)
but as the actual data object is to be printed is not
present at that memory location so it will print what ever
will be the contents of that memory location.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is setfill c++?
Who invented turbo c++?
What is dynamic and static typing?
What is the c++ programming language used for?
What is a dangling pointer in c++?
Which software is used for c++ programming?
What is a singleton class c++?
If you don’t declare a return value, what type of return value is assumed?
Are php strings immutable?
What are stacks?
Why was c++ created?
What is a lambda function c++?
write a corrected statement so that the instruction will work properly. if (4 < x < 11) y = 2 * x;
Can manipulators fall in love?
How do you compile the source code with your compiler?