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 |
simple c program for 12345 convert 54321 with out using string
what is data structure.in linear and non linear data structures which one is better?Explain
WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?
28 Answers 3D PLM, Code Studio, Deltech, IBM,
ratio,age,persentage
What is the meaning When we write "#include" what is # and what does include does there???
How does normalization of huge pointer works?
What language is windows 1.0 written?
Is an array parameter is always "by reference" ?
WAP to accept basic salary of an employee? Calculate it HRA=25%,DA=30%,PF=30%&net salary display all contents?
6 Answers Finite Infotech, Lovely Professional University, Wipro,
What is Lazy evaluation in C? Give an example.
int array[]={1,2,3,4,5,6,7,8}; #define SIZE (sizeof(array)/sizeof(int)) main() { if(-1<=SIZE) printf("1"); else printf("2"); }
Write a program to find whether the given number is prime or not?