Skip to contentSkip to conversation

simple printf

DISCUSSION rinku rathore 2 participants 2 messages Nov 2, 2004

lore
Share & tools
lore
#0 lore raw

hello all,

what may be the out put of simple

printf("%d");

a garbage value or something else
Regards
Rinku

__________________________________
Do you Yahoo!?
Check out the new Yahoo! Front Page.
www.yahoo.com

#1 lore raw
Quoted 5 lines · rinku rathore

what may be the out put of simple

printf("%d");

a garbage value or something else

If you don't specify sufficient arguments, the result is "undefined".

On most common platforms, the function will just read whatever happens to be at the relevant location on the stack. In this specific case, printf() will just print some unspecified integer.

If the argument was a pointer, or an integer which was used in computing a memory address (e.g. an array index), you would probably get a segmentation fault (typically, less than half of the process' address space is actually mapped to anything, so accessing a random memory location would be more likely than not to access an unmapped location).

Signature · 1 line
Glynn Clements <[email protected]>