Quote:
Originally Posted by andryk
Hi,
It'll be on stack i suppose and in general all variables declared inside a function will be on stack as well.
Code:
unsigned long sp(void) {
asm("movl %esp, %eax");
}
void main() {
int *a;
a=malloc(16*sizeof(int));
printf ("addr of a is %p, sp is %p and malloc is %p\n",&a,sp(),a);
}
|
In the above case, a will point to the memory in the heap storage. Heap because of the malloc.
On the other hand, in the following case, a will point to a memory location in the stack.
Code:
int i = 10;
int *a = &i;