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



Answer Posted / vint

int main()
{
char *p1="Name";
char *p2,*s1,*s2;;
p2=(char *)malloc(20);
s1 = p1;
s2 = p2;
while(*p2++ = *p1++);
printf("%s %s",s1,s2);
return 0;
}

Store the Start address of p1 and p2 before incrementing the pointer so that it could be later used to print the String.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the rules for the identifier?

675


Explain how can I make sure that my program is the only one accessing a file?

632


What is difference between function overloading and operator overloading?

664


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

648


in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none

606






What is a protocol in c?

561


Explain what is gets() function?

637


Can we use visual studio for c?

556


Is linux written in c?

603


Explain what is a program flowchart and explain how does it help in writing a program?

652


What is New modifiers?

674


What is the function of this pointer?

677


What are pragmas and what are they good for?

580


How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

598


write a c program to calculate sum of digits till it reduces to a single digit using recursion

2723