What will be the result of the following program?
char*g()
{
static char x[1024];
return x;
}
main()
{
char*g1="First String";
strcpy(g(),g1);
g1=g();
strcpy(g1,"Second String");
printf("Answer is:%s", g());
}
(A) Answer is: First String (B) Answer is: Second String
(C) Run time Error/Core Dump (D) None of these

Answers were Sorted based on User's Feedback



What will be the result of the following program? char*g() { static char x[1024]; return x; } ..

Answer / kalyan chukka

The Answer is Second String

Is This Answer Correct ?    4 Yes 2 No

What will be the result of the following program? char*g() { static char x[1024]; return x; } ..

Answer / abhisheksingh462

Answer is "second string" because both handle same address

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More C Interview Questions

Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer

0 Answers   TCS,


Can one function call another?

0 Answers  


What are the scope of static variables?

0 Answers  


How is a null pointer different from a dangling pointer?

0 Answers  


Explain the use of fflush() function?

0 Answers  






What are the advantages of c preprocessor?

0 Answers  


what is the output of the program and explain why?? #include<stdio.h> void main ( ) { int k=4,j=0: switch (k) { case 3; j=300; case 4: j=400: case 5: j=500; } printf (ā€œ%d\nā€,j); }

14 Answers   Oracle,


what is c programming?

3 Answers   TCS,


What is a static variable in c?

0 Answers  


Why do u use # before include in a C Progam?

9 Answers   IBM,


Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?

7 Answers  


How do I send escape sequences to control a terminal or other device?

0 Answers  


Categories