I'm trying to understand uninitialized pointers in functions as a local variable. here is my code:
#include <stdio.h>
#include <string.h>
void big_p() {
char big[150];
memset(big, 'B', 150);
}
void ptr_init() {
char *p;
char x = 'X';
printf("P value: %p\n", p);
}
int main()
{
big_p();
ptr_init();
}
I have some questions:
- the pointer p is pointing to a random memory address! why it contains 0x424242... (hex of 'B')?
- if I remove the line "char x = 'X'; " the pointer p does not contains hex of 'B', why?!
thank you.