I tried to just allocate memory on the stack and heap in C.
int x = 2; int *y = malloc(sizeof(int));
When I look at the address x on the stack and the heap address contained in y, I see the following
x stack address : 0xbfe92bb4 heap address in y : 0x 9c4b008
Are these addresses in a different format (since I do not see the same hexadecimal characters in both of them)?
There are three main types of distributions in a conventional software model:
- , - ( -), (, , , ) ( ).
- ( , , 0x09c4b008, 0 ).
.
, . -. , , char s [] = "hello world" C, C, int debug = 1 , . C, const char * string = "hello world" , "hello world" -. : int = 10 , int = 10
Heap BSS . "" malloc, realloc free, brk sbrk ( , brk/sbrk " " malloc/realloc/free, mmap . .
wikipedia
Malloc , , .
The different format is not the difference in format, but simply the fact of where the memory exists in the process space, which partially depends on the decision of the compiler and the OS when allocating the heap of space for malloc.
See also this question , which has much more detailed information.