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



Answer Posted / shruti

-> while(*p2++ "=" *p1++)
the syntax of while is
while("condition");

in condition statement the assignment operator is used in a
wrong way..
when we are using loop it should be "=="..

we cannot copy the value of p1 in p2, the way its mentioned
here..


** It will either give an error or display some garbage
value in p2 , or no value..
depends on what p2 is initialised to implicitly..

Is This Answer Correct ?    1 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are linker error?

606


Why do we use pointer to pointer in c?

586


What are terms in math?

577


What is sizeof in c?

561


Explain the difference between malloc() and calloc() function?

591






What is spark map function?

572


Write a code to generate divisors of an integer?

626


Explain the use of keyword 'register' with respect to variables.

584


If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

770


Can we compile a program without main() function?

622


FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above

613


Explain how do you generate random numbers in c?

612


What are the advantage of c language?

541


What is context in c?

529


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

650