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
How much do coding jobs pay?
Which bit wise operator is suitable for putting on a particular bit in a number?
What is a v-table?
What is the difference between global int and static int declaration?
How do we implement inheritance in c++?
Tell me an example where stacks are useful?
Is c++ a float?
Explain unexpected() function?
What is the output of the following program? Why?
How can you quickly find the number of elements stored in a static array?
What is the importance of mutable keyword?
How do you find out if a linked-list has an end?
What are the rules for naming an identifier?
Can class objects be passed as function arguments?
Is it possible for a member function to delete the pointer, named this?