Re: [algogeeks] Allocating memory of size 0

2012-06-02 Thread Karthikeyan V.B
It does not return a valid address. The result of malloc(0) is implementation defined and therefore unreliable. Some compiler implementations will cause it to return a NULL pointer, others may return some other value (but it still can't/shouldn't be used to access memory). The memory cannot be u

[algogeeks] Allocating memory of size 0

2012-06-02 Thread Prakhar Jain
Hi everyone, Someone plz explain why this C code works fine as memory allocated is of 0 size... main() { int *p=malloc(0); *p=2566; printf("%d\n",*p); getchar(); } -- Prakhar Jain IIIT Allahabad B.Tech IT 3rd Year Mob no: +91 9454992196 E-mail: rit2009...@iiita.ac.in