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
Are the outer parentheses in return statements really optional?
When should a type cast be used?
What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }
#include
Write a program to implement queue.
What is indirection in c?
Explain what are the __date__ and __time__ preprocessor commands?
Write a program to find factorial of a number using recursive function.
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
What is the mean of function?
explain what is an endless loop?
How many types of arrays are there in c?
Can we declare function inside main?
What are the 5 organizational structures?
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above