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 / deepa
the outpu is hello coz the pointer is pointing to a
location where the string "bye" is written in the next
program yu are using the same pointer to point to some
other string so it gets overwritten
| Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
What is 1f in c?
What tq means in chat?
Do you know the use of 'auto' keyword?
Is anything faster than c?
write a c program to calculate sum of digits till it reduces to a single digit using recursion
Describe wild pointers in c?
In which language linux is written?
What is multidimensional arrays
How can I automatically locate a programs configuration files in the same directory as the executable?
Can a local variable be volatile in c?
What are the 4 types of functions?
Explain how can you tell whether a program was compiled using c versus c++?
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above
Difference between exit() and _exit() function?
What is quick sort in c?