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 is pointers in c?
How are pointers declared in c?
List a few unconditional control statement in c.
Explain what is #line used for?
Explain what does a function declared as pascal do differently?
Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.
Which function in C can be used to append a string to another string?
Explain how can I read and write comma-delimited text?
Difference between malloc() and calloc() function?
write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays
Why enum is used in c?
What are global variables and explain how do you declare them?
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
When should the register modifier be used? Does it really help?
design and implement a data structure and performs the following operation with the help of file (included 1000 student marks in 5 sub. and %also) 1.how many students are fail in all 5 subjects (if >35) 2. delete all student data those are fail in all 5 subjects. 3. update the grace marks (5 no. if exam paper is 100 marks) 4. arrange the student data in ascending order basis of marks. 5.insert double of deleted students with marks in the list.