As you note, abc
is not properly initialized, so we do not know what it points to. Before it can be reliably used, it must be assigned a value that is the address of properly reserved memory. You can assign it a value by assigning it the address of a defined object (as in int x; int *abc = &x;
) or by requesting memory through a routine such as malloc
(as in int *abc = malloc(sizeof *abc);
and checking that the result is not NULL
).
Note that it is not correct to say that it “points to random stuff.” In the terms of the C standard, its value is indeterminate. This means its value is not only unspecified, but that a program that uses it might behave as if abc
has a different value each time it is used—it does not necessarily act as if abc
has some single randomly determined value. It might also have a trap representation, which does not represent a value of pointer type, and using it would result in the behavior of the program not being defined by the C standard.