enquiry about pointer

hello friends

i would like to know why i cann't use the following code..

int* ptr;
*ptr=23;

i already know that there is a segmentation fault if i use that, but i'd like to know the theoretical reason..

thanks in advance
Because your pointer does not point to anything, and thus when you dereference it, you're writing to a garbage address, potentially corrupting RAM.
Topic archived. No new replies allowed.