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
What are qualifiers and modifiers c?
What is #define in c?
What is a far pointer in c?
code for replace tabs with equivalent number of blanks
Are global variables static in c?
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
How can I use a preprocessorif expression to ?
What is the scope of an external variable in c?
what are the different storage classes in c?
What is zero based addressing?
Write a program to reverse a string.
What is a null string in c?
What is a good way to implement complex numbers in c?
What are run-time errors?
Is boolean a datatype in c?