C Programming - Memory Allocation - Discussion

Discussion Forum : Memory Allocation - Find Output of Program (Q.No. 2)
2.
What will be the output of the program (16-bit platform)?
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int *p;
    p = (int *)malloc(20);
    printf("%d\n", sizeof(p));
    free(p);
    return 0;
}
4
2
8
Garbage value
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
31 comments Page 4 of 4.

Asha said:   1 decade ago
Here P is integer pointer used for storing the address and address is always 2 bytes hence sizeof P is 2 bytes.


Post your comments here:

Your comments will be displayed after verification.