main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
Answer Posted / 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 |
Post New Answer View All Answers
What are the disadvantages of a shell structure?
Calculate 1*2*3*____*n using recursive function??
How arrays can be passed to a user defined function
How are portions of a program disabled in demo versions?
Explain what is the difference between #include and #include 'file' ?
What is a nested formula?
What is merge sort in c?
Explain the bubble sort algorithm.
What is void main () in c?
What is the difference between char array and char pointer?
what is the difference between class and unio?
how to write optimum code to divide a 50 digit number with a 25 digit number??
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
How do you use a pointer to a function?
How can I make sure that my program is the only one accessing a file?