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 |
how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?
Is an array parameter is always "by reference" ?
What is static memory allocation? Explain
What is the use of structure padding in c?
What is the use of a semicolon (;) at the end of every program statement?
Which is an example of a structural homology?
C program to find all possible outcomes of a dice?
If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402
C program to find frequency of each character in a text file?
Consider the following C program. #include <stdio.h> int main() { int i; for (i=0;i<3;++i) { fork();fork(); } } How many processes are created when running this program (including the initial one)? Explain
How does #define work?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference