Reputation: 3
If you declare a pointer in C and don't give it a NULL value, then is that pointer's memory address still reserved AKA it can't be taken over by no data till you give it a real value or NUll value. This got me thinking. Thank you in advance:)
Upvotes: 0
Views: 418
Reputation: 223927
If any variable is left uninitialized, and it is not declared at file scope or with the static
qualifier, its value is indeterminate. If a variable with an indeterminate value is read, and if that variable never has its address taken, then attempting to do so triggers undefined behavior.
In practice, this means it could hold any value, and that value need not be the same on subsequent reads. On some architectures it could even be a trap representation, where just reading the value can cause a crash.
Upvotes: 1