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 are enumerated types?
How do you initialize function pointers? Give an example?
Write a program to identify if a given binary tree is balanced or not.
what is the self-referential structure?
What is the meaning of 2d in c?
What is call by reference in functions?
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
Write a code of a general series where the next element is the sum of last k terms.
What language is c written?
Can we access RAM? How? Whats the range of access? Similarly What are other hardware we can access?
the maximum value that an integer constant can have is a) -32767 b) 32767 c) 1.701e+38 d) -1.7014e+38
What is the difference between exit() and _exit() function in c?