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


Please Help Members By Posting Answers For Below Questions

What is pointers in c?

659


How are pointers declared in c?

602


List a few unconditional control statement in c.

561


Explain what is #line used for?

609


Explain what does a function declared as pascal do differently?

643






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.

1597


Which function in C can be used to append a string to another string?

648


Explain how can I read and write comma-delimited text?

660


Difference between malloc() and calloc() function?

655


write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays

1787


Why enum is used in c?

525


What are global variables and explain how do you declare them?

581


5 Write an Algorithm to find the maximum and minimum items in a set of ā€˜nā€™ element.

1583


When should the register modifier be used? Does it really help?

616


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.

1498