what will be the output?

Discussion in 'C' started by indian.21987, Aug 21, 2007.

Thread Status:
Not open for further replies.
  1. indian.21987

    indian.21987 New Member

    Joined:
    Aug 19, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    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 a moderator: Aug 21, 2007
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice