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

whats the use of header file in c?

2 Answers  


What is maximum size of array in c?

0 Answers  


There is a 100-story building and you are given two eggs. The eggs (and the building) have an interesting property that if you throw the egg from a floor number less than X, it will not break. And it will always brake if the floor number is equal or greater than X. Assuming that you can reuse the eggs which didn't broke; you got to find X in a minimal number of throws. Give an algorithm to find X in minimal number of throws.

5 Answers   Yahoo,


What is binary tree in c?

0 Answers  


What is the ANSI C Standard?

0 Answers   Celstream,






what is the importance of spanning tree?

0 Answers  


main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }

4 Answers   CTS,


7. Identify the correct argument for the function call fflush() in ANSI C: A)stdout B)stdin C)stderr D)All the above

10 Answers   Accenture,


1. What will be the output of the following programs. a) #include <stdio.h> Main() { Int x=4; While(x==1) { X=x-1; Printf(ā€œ%dā€,x); --x; } }

7 Answers   CSC,


Write a program to generate the Fibinocci Series

0 Answers   TISL,


Write a program to generate random numbers in c?

0 Answers  


How do I get an accurate error status return from system on ms-dos?

0 Answers  


Categories