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
Write a program to check prime number in c programming?
How do you print only part of a string?
Why void main is used in c?
What is the use of void pointer and null pointer in c language?
What are the Advantages of using macro
Where define directive used?
What is difference between %d and %i in c?
What are qualifiers?
What is the acronym for ansi?
Why do we need a structure?
How can I avoid the abort, retry, fail messages?
What is maximum size of array in c?
What is the function of multilevel pointer in c?
Explain what is the use of a semicolon (;) at the end of every program statement?
Explain how can you avoid including a header more than once?