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

What are qualifiers and modifiers c?

537


What is #define in c?

607


What is a far pointer in c?

588


code for replace tabs with equivalent number of blanks

1629


Are global variables static in c?

664






Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

572


How can I use a preprocessorif expression to ?

592


What is the scope of an external variable in c?

561


what are the different storage classes in c?

654


What is zero based addressing?

700


Write a program to reverse a string.

628


What is a null string in c?

577


What is a good way to implement complex numbers in c?

582


What are run-time errors?

592


Is boolean a datatype in c?

535