ఎవరికైనా తెలుసా malloc(0) పనిచేస్తుంది

#include
#include

int main()
{
    int *p;
    printf("Hello world!\n");

    p = malloc(0);
    *p = 1000000;
    printf("%d %d\n",p,(int)*p);
    free(p);
    return 0;
}

ఈ program correct గా పనిచేస్తుంది

1 comment:

  1. See C99, section 7.20.3:

    If the size of the space requested is zero, the behavior is implementationdefined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object.

    ReplyDelete

తెలుగులో వ్రాయడానికి http://www.google.com/ime/transliteration/ ఉపయోగించండి.