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

Answer Posted / subbu[iit kgp]

the given program gives some meaningless output, with some
modification to the given program as


#include<stdio.h>
#include<stdlib.h>
main()
{
char a[]="ramesh";
char *p1="Name";
char *p2=a;

while(*p2++=*p1++);/*copies contents of p1 to
p2*//* here it is not possible to use while(*a++=*p1++)
because a can not change its value*/
*p2='\0';
printf("%s\n",a);

}

The output will be Name

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is a stream?

606


application attempts to perform an operation?

1487


What is linear search?

672


any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above

628


What is array of structure in c?

590






shorting algorithmS

1798


How do I send escape sequences to control a terminal or other device?

604


How many types of sorting are there in c?

604


What is the purpose of sprintf?

615


What are directives in c?

539


What is a MAC Address?

624


Difference between constant pointer and pointer to a constant.

607


Explain how can you tell whether two strings are the same?

580


Why do we need functions in c?

551


Explain high-order bytes.

670