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

It will show "HELL"
the f function reserve only 4 bytes with the sizeof(6). it will return the sizeof (int) =4 bytes.
So you only allocate 4 bytes.
When performing the strcpy, you will corupt memory because you'll copy more than allocate.

Cheers

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

1333


Multiply an Integer Number by 2 Without Using Multiplication Operator

761


Explain what is #line used for?

1061


What are logical errors and how does it differ from syntax errors?

1293


What is p in text message?

978


What are the string functions? List some string functions available in c.

990


Write a program to generate the Fibinocci Series

1231


What is #define in c?

1044


What does char * * argv mean in c?

1053


What is the difference between strcpy() and memcpy() function in c programming?

1083


What is scope rule of function in c?

1085


What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.

2257


What is static and auto variables in c?

1084


What is a program flowchart and explain how does it help in writing a program?

1304


Does free set pointer to null?

1001