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...

what will be the result of the following program ?
char *gxxx()
{
static char xxx[1024];
return xxx;
}

main()
{
char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is :
%s",gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these

Answer Posted / jaya prakash

b) The String is :OldString

Because ,for Static var memory is only one time created.
Eventhough the fn is multiple times called,
so
consider addr of xxx is 4444,
first strcpy copy the string "string" to addr 4444,
then g=4444;
then oldstring overwrites to location 4444.

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages of using macro in c language?

1136


hi, which software companys will take,if d candidate's % is jst 55%?

2093


Do array subscripts always start with zero?

1307


What is the difference between procedural and functional programming?

1081


What are linked lists in c?

1132


Why #include is used in c language?

1054


please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

1777


How many levels of pointers have?

1056


What does *p++ do? What does it point to?

1065


List some of the static data structures in C?

1202


What is extern c used for?

1065


What is the difference between array and pointer in c?

1165


What is the role of this pointer?

1075


Write a program to check palindrome number in c programming?

1022


Explain how can you tell whether two strings are the same?

1020