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



Answer Posted / ali fakoor

A part of uninitialized (and/or unowned) memory after (and
including) the sixth byte of the malloc-ed memory will be
printed out until reaching a NULL character in the memory
somewhere!

Is This Answer Correct ?    6 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is s or c?

586


What are the Advantages of using macro

675


What is wrong with this initialization?

577


Can a function argument have default value?

656


Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.

3681






If you know then define #pragma?

668


What is #include cctype?

570


What is scope rule of function in c?

539


Explain what is the difference between the expression '++a' and 'a++'?

620


What is the best way of making my program efficient?

559


simple program of graphics and their output display

1462


Why c language?

636


How can I convert a number to a string?

600


What is the correct code to have following output in c using nested for loop?

603


What does the c preprocessor do?

609