printf function help

Alan Dayley plug-devel@lists.PLUG.phoenix.az.us
Mon Mar 1 13:02:05 2004


Tarun Karra wrote:

> hi,
>  
> Iam sorry i think i didnt make the question right first time
>  
> Can you please run the program below and give me a reason for the output
> #include <stdio.h>
> int main()
> {
> printf("%d") ;
> return 0;
> }
> watchout
>  > printf("%d",x) ;
> there is no x my program. Its only **********printf("%d") 
> ;******************
> my program still compiles and prints out value 34603777
>  
> Can any one give me a reason for this output.

Rob's explaination is probably correct.  C allows you to do "stupid" 
things, including printing a pointer value that you did not intend.  Use 
the warnings and you will be informed when something is amiss.

I have a follow-up question for you:  Since this statement has no 
variable argument, why do you want to know why it prints some bogus 
value?  It is an invalid statement therefore the output is invalid.  Why 
do you care?

Alan