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 does c mean before a date?

868


Explain how can I convert a string to a number?

876


What are the different types of linkage exist in c?

820


What header files do I need in order to define the standard library functions I use?

784


What is pragma in c?

873


Is main a keyword in c?

863


What are the types of pointers in c?

767


Where static variables are stored in c?

817


What was noalias and what ever happened to it?

802


a c code by using memory allocation for add ,multiply of sprase matrixes

2560


Is c a great language, or what?

876


Explain output of printf("Hello World"-'A'+'B'); ?

1203


Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor

3269


What are structures and unions? State differencves between them.

873


please give me some tips for the placement in the TCS.

1872