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 / yathish m yadav
the output is "hello".
here we are overwriting pointer *p thrice.
that is in the function we get an piece of memory from
malloc and assigned to p,
in the statement strcpy(p,"hello");
the malloc memory is lost and the compiler creates an char
array and copies the string "hello" and it makes the
character array as constant.
Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above
What is #include called?
Where is volatile variable stored?
Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)
Explain indirection?
What is a static variable in c?
How to delete a node from linked list w/o using collectons?
What extern c means?
What header files do I need in order to define the standard library functions I use?
What is a rvalue?
What is the difference between formatted&unformatted i/o functions?
Can you define which header file to include at compile time?
"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above
Is c procedural or functional?
What is a node in c?