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 / anu

the output wll be hello , since the argument is overwritten
with new memory in the function.

so in main, when it comes to printf, p points to the
allocatd memory, which contains hello

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a node in c?

539


Is there a way to jump out of a function or functions?

623


What are global variables and explain how do you declare them?

561


Array is an lvalue or not?

623


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

2563






Explain why can’t constant values be used to define an array’s initial size?

843


What is a pointer and how it is initialized?

593


Why is sprintf unsafe?

607


c program to compute AREA under integral

1796


What does dm mean sexually?

799


hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

1649


What does %c mean in c?

637


Why do we use & in c?

579


What is the advantage of c?

604


What is restrict keyword in c?

631