What will be result of the following program?void myalloc(char *x, int n){x= (char *)malloc(n*sizeof(char));memset(x,,n*sizeof(char));}main(){char *g="String";myalloc(g,20);strcpy(g,"Oldstring");printf("The string is %s",g);}a) The string is : Stringb) Run time error/Core dumpc) The string is : Oldstringd) Syntax error during compilatione) None of these

Showing Answers 1 - 3 of 3 Answers

Zhang Long

  • Nov 23rd, 2007
 

the answer B is right, cause g is a pointer to a constant string, so the function strcpy will fail.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions