main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
what is the output?
Answer Posted / vint
int main()
{
char *p1="Name";
char *p2,*s1,*s2;;
p2=(char *)malloc(20);
s1 = p1;
s2 = p2;
while(*p2++ = *p1++);
printf("%s %s",s1,s2);
return 0;
}
Store the Start address of p1 and p2 before incrementing the pointer so that it could be later used to print the String.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Write a program to print “hello world” without using semicolon?
Is that possible to add pointers to each other?
What is assert and when would I use it?
given post order,in order construct the corresponding binary tree
Explain main function in c?
Which is better pointer or array?
How can I swap two values without using a temporary?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
How can I call fortran?
What is scanf () in c?
What is a rvalue?
Why is c so powerful?
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
Why #include is used in c language?
What is dynamic memory allocation?