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
Can a pointer point to null?
What is variable initialization and why is it important?
How can you determine the size of an allocated portion of memory?
Can main () be called recursively?
How can I get back to the interactive keyboard if stdin is redirected?
What is meant by 'bit masking'?
What is the purpose of sprintf?
How can I automatically locate a programs configuration files in the same directory as the executable?
What does the format %10.2 mean when included in a printf statement?
Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.
Explain can static variables be declared in a header file?
What are identifiers c?
which is an algorithm for sorting in a growing Lexicographic order
Why can’t constant values be used to define an array’s initial size?
What is an arrays?