#include
int main(void)
{
int *ptr;
printf(\"%p\", ptr); // Error: uninitialized local variable \'ptr\' used
// Outpu
The contents of an unitialized auto
variable (pointer type or otherwise) are indeterminate; in practice, it's whatever was last written to that memory location. The odds that this random bit pattern corresponds to a valid address1 in your program are pretty low; it may even be a trap representation (a bit pattern that does not correspond to a legal value for the type).
Attempting to dereference an invalid pointer value results in undefined behavior; any result is possible. Your code may crash outright, it may run with no apparent issues, it may leave your system in a bad state.
malloc
or similar.