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


Please Help Members By Posting Answers For Below Questions

If I have a char * variable pointing to the name of a function ..

886


How can I insert or delete a line (or record) in the middle of a file?

767


How can I implement sets or arrays of bits?

793


What are dangling pointers in c?

815


How does sizeof know array size?

822






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

1292


What is the difference between malloc calloc and realloc in c?

868


How can a program be made to print the name of a source file where an error occurs?

965


Write a Program to accept different goods with the number, price and date of purchase and display them

5846


What does *p++ do?

779


What are the types of data types and explain?

837


What is the difference between single charater constant and string constant?

832


Explain what are preprocessor directives?

808


What is the size of array float a(10)?

878


Explain how can type-insensitive macros be created?

752