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
If I have a char * variable pointing to the name of a function ..
How can I insert or delete a line (or record) in the middle of a file?
How can I implement sets or arrays of bits?
What are dangling pointers in c?
How does sizeof know array size?
Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58
What is the difference between malloc calloc and realloc in c?
How can a program be made to print the name of a source file where an error occurs?
Write a Program to accept different goods with the number, price and date of purchase and display them
What does *p++ do?
What are the types of data types and explain?
What is the difference between single charater constant and string constant?
Explain what are preprocessor directives?
What is the size of array float a(10)?
Explain how can type-insensitive macros be created?