main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
what is the output?



Answer Posted / sanath

ANS: NULL
It is a bit tricky question. If u observe carefully then we
are incrementing the pointers p1,p2. When it reached the end
of the string, *p2 points to NULL. We have lost the address
of the starting position.

Is This Answer Correct ?    40 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1650


What is a #include preprocessor?

612


swap 2 numbers without using third variable?

656


What is structure padding and packing in c?

614


how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.

1209






Explain built-in function?

587


What are the 3 types of structures?

568


How can I call fortran?

640


How many types of sorting are there in c?

604


What is nested structure?

567


Why is this loop always executing once?

615


How many levels of pointers can you have?

695


What is the use of bit field?

635


Explain how many levels deep can include files be nested?

622


What does a pointer variable always consist of?

659