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

Run time error/Core dump.

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how many errors in c explain deply

1631


c language interview questions & answer

1463


Explain pointer. What are function pointers in C?

628


How can I do graphics in c?

597


Does free set pointer to null?

565






What are c preprocessors?

679


How can I do peek and poke in c?

622


What is abstract data structure in c?

531


Is using exit() the same as using return?

680


What is a protocol in c?

559


Explain how do you determine the length of a string value that was stored in a variable?

670


Why do we use & in c?

593


What is scanf () in c?

664


What are conditional operators in C?

627


write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

1645