what will be the output?

indian.21987's Avatar
Light Poster
Code:
main() 
{ 
        char *p1=“name”; 
        char *p2; 
        p2=(char*)malloc(20); 
        memset (p2, 0, 20); 
        while(*p2++ = *p1++); 
        printf(“%s\n”,p2); 

}

Also what is the use of malloc() function?

Last edited by shabbir; 21Aug2007 at 14:53.. Reason: Code block
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Duplicate of what will the output?. Thread closed.