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


Please Help Members By Posting Answers For Below Questions

What is c language & why it is used?

574


Explain the use of 'auto' keyword

673


Differentiate between functions getch() and getche().

617


What are the rules for the identifier?

667


How do I read the arrow keys? What about function keys?

610






What is const volatile variable in c?

572


Explain how do you declare an array that will hold more than 64kb of data?

895


Explain that why C is procedural?

652


Can variables be declared anywhere in c?

614


What is the general form of a C program?

596


What is the difference between text files and binary files?

670


How do you view the path?

658


any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above

650


Can a pointer be volatile in c?

530


Write a program to check prime number in c programming?

592