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
Explain what is a stream?
application attempts to perform an operation?
What is linear search?
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
What is array of structure in c?
shorting algorithmS
How do I send escape sequences to control a terminal or other device?
How many types of sorting are there in c?
What is the purpose of sprintf?
What are directives in c?
What is a MAC Address?
Difference between constant pointer and pointer to a constant.
Explain how can you tell whether two strings are the same?
Why do we need functions in c?
Explain high-order bytes.