I have structure containing an array. Something like given below:
struct Node
{
int a;
char a1[25];
}obj;
main()
{
struct Node *p = malloc(sizeof(struct Node));
p->a=10;
}
I would like to know is two different memory section is allocated for this piece of code one from stack for storing structure node and other from heap for storing node pointed to by pointer p?
After Edit:
Instead it will be allocated in data section I guess. This code is modified little-bit like
And when we look at assembly code.
both global_data and obj allocated in same location. i.e uninitialized data section. There will be no chance to allocate in heap. Because there is no call to malloc().