Why do declared but uninitialized pointers have a value in code blocks?

13 Views Asked by At

Hello I have a problem with pointers in C where I dont really know how codeblocks handles pointers when they are only declared but uninitialized as followed:

char *badString; printString(badString);

The printString() function has the following logic that should detect if the entered string is NULL:

assert(enteredString != NULL);

But it turns out the pointer actually has a value? If I print out the pointer it returns an actuall memory address for some reason:

printf("%p.\n", s); //in my case that is 72 in decimal

I dont really know what to do since the tutorial does not have the same problem and I am pretty new to C so my educated guess would be that it has something to do with codeblocks but if I did something wrong I would like to understand it so I can avoid it in the future. This is the tutorial that I am follwoing if that is relevant: https://www.youtube.com/watch?v=4cL5WwBnwCw&list=PLA1FTfKBAEX4hblYoH6mnq0zsie2w6Wif&index=82 . Thanks in advance :)

0

There are 0 best solutions below