Microsoft Interview Question
Software Engineer in TestsCountry: India
@aniket: What's n? There's no n anywhere in this problem. If you allocated an array of some size n through malloc and assigned the address of the start of this array to one of these pointers, the memory for the array would be on the heap and not on the stack, and it would still be the case that only the pointer would be on the stack. The answer as to the amount of on-stack memory used would still be what I said.
is it correct to say that sizeof (int*) = 32 bits
and sizeof (char*)= 32 bits so 8 bytes? or am i making a certain assumption?
is it correct to say that sizeof (int*) = 32 bits
and sizeof (char*)= 32 bits so 8 bytes? or am i making a certain assumption?
um guys.... Pointers don't take memory from stack right? O.o They take it from heap. Shouldn't answer be 0?
I think a good answer is sizeof (int*) + sizeof (char*), provided those declarations are not optimized away.
- eugene.yarovoi October 23, 2011