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



Answer Posted / vadivel t

In addtion to the answer #5.

printf("%s\n",p2); will print the values from 6th byte to
20th byte.

6th byte to 20th bytes of the memory will contain some
Garbage value. So the output will be a string of garbage
values.


For desired o/p see the ans #5

Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is a constant pointer in C

664


What is main () in c?

580


what is recursion in C

601


Why cant I open a file by its explicit path?

587


What are register variables in c?

564






What is #include conio h?

584


What is the best way to comment out a section of code that contains comments?

772


what are enumerations in C

716


When we use void main and int main?

577


List the difference between a "copy constructor" and a "assignment operator"?

574


What is the best style for code layout in c?

624


How to create struct variables?

581


Is there a way to compare two structure variables?

610


What is the c language function prototype?

638


Explain the difference between ++u and u++?

633