Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / shruti

The output would be "HELLO"..

though we are not returning the string, we are making
direct changes at the memory location..

so "bye" will be overwritten with "HELLO"


because we are using pointers, the dying pointer scenario
is not applicabe here..

Its a pointer, not a variable..


This function will work similar to -> swapping two numbers
using pointers..
juss check that prog if you fnd somewhere.. :-)
you will get the logic... :-)


Cheers...


--By the way a gud ques.. :-)

Is This Answer Correct ?    1 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about the constants which help in debugging?

1301


What are structures and unions? State differencves between them.

1096


What is the size of enum in c?

1051


What is variable initialization and why is it important?

1160


What is clrscr ()?

1051


Does c have class?

1049


a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list

1010


Can we increase size of array in c?

917


Is linux written in c?

986


What is enumerated data type in c?

1030


What are the data types present in c?

1088


Is a pointer a kind of array?

1111


What is a newline escape sequence?

1051


What are the different types of errors?

1069


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

1217