f(char *p)
{
p=(char *)malloc(sizeof(6));
strcpy(p,"HELLO");
}
main()
{
char *p="BYE";
f(p)
printf("%s",p);
}
what is the output?

Answer Posted / vijay

The out put is "BYE".
Because the pointer p dies when function exit with out
return,in main pointer p points to only "BYE",so prinf
prints which p points in main.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain pointers in c programming?

620


Can you add pointers together? Why would you?

627


What is size of union in c?

567


What are # preprocessor operator in c?

615


When should you use a type cast?

574






What are identifiers in c?

615


Which is best book for data structures in c?

583


Explain what are the advantages and disadvantages of a heap?

587


What are type modifiers in c?

603


Why is a semicolon (;) put at the end of every program statement?

609


Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.

2638


Is a house a mass structure?

630


can anyone please tell about the nested interrupts?

1666


In which language linux is written?

591


What is wrong with this statement? Myname = 'robin';

800