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
Post New Answer View All Answers
Where register variables are stored in c?
Which is better malloc or calloc?
how do you execute a c program in unix.
What is a structure and why it is used?
Where define directive used?
Can a variable be both static and volatile in c?
Simplify the program segment if X = B then C ← true else C ← false
Where are local variables stored in c?
Why dont c comments nest?
What is a newline escape sequence?
Is the exit() function same as the return statement? Explain.
What is the most efficient way to count the number of bits which are set in an integer?
Can we replace the struct function in tree syntax with a union?
why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above
Write a progarm to find the length of string using switch case?