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


Please Help Members By Posting Answers For Below Questions

the maximum length of a character constant can be a) 2 b) 1 c) 8

858


Explain the different access specifiers for the class member in c++.

736


What are register variables?

815


What is the fastest c++ compiler?

753


What are the 3 levels of programming languages?

756






Define stacks. Provide an example where they are useful.

757


Discuss the effects occur, after an exception thrown by a member function is unspecified by an exception specification?

815


What is lambda in c++?

870


Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).

800


What is the basic of c++?

786


How do I get good at c++ programming?

818


What's the best free c++ profiler for windows?

812


Do vectors start at 0 c++?

727


Why is c++ is better than c?

695


what are the characteristics of Class Members in C++?

793