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 is the difference between new and malloc functions?

587


Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above

666


What does do in c?

619


Explain null pointer.

630


How do I read the arrow keys? What about function keys?

624






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 []);

1856


#include #include struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

5227


Explain how do you list files in a directory?

626


What is const and volatile in c?

576


FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above

632


How do shell structures work?

581


Do you know the use of fflush() function?

608


How to draw the flowchart for structure programs?

8768


How can I implement a delay, or time a users response, with sub-second resolution?

635


Why enum is used in c?

542