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 result of the following program?
void myalloc(char *x, int n)
{
x= (char *)malloc(n*sizeof(char));
memset(x,\0,n*sizeof(char));
}
main()
{
char *g="String";
myalloc(g,20);
strcpy(g,"Oldstring");
printf("The string is %s",g);
}
a) The string is : String
b) Run time error/Core dump
c) The string is : Oldstring
d) Syntax error during compilation
e) None of these

Answer Posted / rishabh taneja

correct the line: memset(x,\0,n*sizeof(char)); as
memset(x,'\0',n*sizeof(char));

Result(if the line mentioned is corrected):
The string is: Oldstring


The result is verified by me by actually running it.

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which header file is essential for using strcmp function?

1423


What are the advantages of the functions?

1097


"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks

1062


Differentiate between null and void pointers.

1117


What is void main ()?

1012


What are identifiers c?

1020


An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode

1032


Is it better to use malloc() or calloc()?

1065


List out few of the applications that make use of Multilinked Structures?

2110


What are the types of assignment statements?

1006


What do you mean by a sequential access file?

1042


What is the value of uninitialized variable in c?

977


How can I do peek and poke in c?

1038


What is wrong in this statement? scanf(ā€œ%dā€,whatnumber);

1190


What is struct node in c?

1021