main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / vignesh1988i
actually in this problem, the p2 will take characters after '\0' too from p1 upto the size of p2 come to an end.
so it prints
output :
Name #^$&dhd
thank u
| Is This Answer Correct ? | 1 Yes | 1 No |
What is the difference between test design and test case design?
HOW TO HANDLE EXCEPTIONS IN C
What is c value paradox explain?
what is the output of the following code? main() { int I; I=0x10+010+10; printf("x=%x",I); } give detailed reason
Why do we need volatile in c?
Can 'this' pointer by used in the constructor?
What is Dynamic Initialization.
Are comments included during the compilation stage and placed in the EXE file as well?
how to execute with out main in cprogram
program to find the magic square
Who developed c language and when?
How arrays can be passed to a user defined function