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



Answer Posted / sanath

ANS: NULL
It is a bit tricky question. If u observe carefully then 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.

Is This Answer Correct ?    40 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to check prime number in c programming?

601


How do you print only part of a string?

618


Why void main is used in c?

562


What is the use of void pointer and null pointer in c language?

633


What are the Advantages of using macro

688






Where define directive used?

609


What is difference between %d and %i in c?

698


What are qualifiers?

617


What is the acronym for ansi?

633


Why do we need a structure?

590


How can I avoid the abort, retry, fail messages?

665


What is maximum size of array in c?

586


What is the function of multilevel pointer in c?

672


Explain what is the use of a semicolon (;) at the end of every program statement?

740


Explain how can you avoid including a header more than once?

605