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

When is a void pointer used?

766


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

914


What is difference between structure and union in c programming?

665


Is return a keyword in c?

709


What is a ternary operator in c?

756






What is omp_num_threads?

687


What are the 32 keywords in c?

747


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

2214


how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?

1596


please explain every phase in the "SDLC" in the dotnet.

2278


What is a program flowchart and explain how does it help in writing a program?

789


What is the use of the function in c?

694


What is break statement?

727


What is ponter?

886


What does stand for?

704