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 / v.prasad

a)the string is string

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are multidimensional arrays?

652


What is typedf?

662


How can I get random integers in a certain range?

609


Explain what are header files and explain what are its uses in c programming?

621


how could explain about job profile

1446






What is a nested loop?

641


What is modifier & how many types of modifiers available in c?

602


Explain how do you override a defined macro?

577


Can we declare a function inside a function in c?

574


What is actual argument?

585


What is pointer and structure in c?

559


What are the different properties of variable number of arguments?

657


What is keyword in c?

595


What is c programming structure?

614


Discuss the function of conditional operator, size of operator and comma operator with examples.

673