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
Why calloc is better than malloc?
What is meant by type casting?
What is actual argument?
How can I determine whether a machines byte order is big-endian or little-endian?
What are valid signatures for the Main function?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
What are the basic data types associated with c?
What is the purpose of 'register' keyword?
cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration
What are the types of bitwise operator?
What does struct node * mean?
What is data structure in c programming?
Compare and contrast compilers from interpreters.
Can static variables be declared in a header file?
Where static variables are stored in c?