What is the Output ?



What is the Output ?

main () 
  {
  char *p1="Name"; 
  char *p2; 
  p2=(char *)malloc(20); 
  while(*p2++=*p1++); 
  printf("%s\n",p2); 
  } 

Answer : NULL

  • We are incrementing the pointers p1,p2.
  • When it reached the end of the string, *p2 points to NULL.
  • We have lost the address of the starting position.

Related Searches to What is the output ?