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
What is the difference between new and malloc functions?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
What does do in c?
Explain null pointer.
How do I read the arrow keys? What about function keys?
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
#include
Explain how do you list files in a directory?
What is const and volatile in c?
FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above
How do shell structures work?
Do you know the use of fflush() function?
How to draw the flowchart for structure programs?
How can I implement a delay, or time a users response, with sub-second resolution?
Why enum is used in c?