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

#define MAX(x,y) (x) > (y) ? (x) : (y) main() { int i = 10, j = 5, k = 0; k = MAX(i++, ++j); printf("%d %d %d", i,j,k); } what will the values of i , j and k? }

14 Answers   CDAC, GATE, NDS, TCS,


my name is nani i completed my b-tech in hyd now i want go for interveiw but i dont know the process of software field interveiws plz help me anyone how many rouds there n what rounds plz plz plz help me n where i can get these details

2 Answers  


write a program in c language for the multiplication of two matrices using pointers?

8 Answers   Ignou,


How are pointers declared in c?

0 Answers  


given post order,in order construct the corresponding binary tree

0 Answers   S-Cube, Wipro,






What is Your Name :)

1 Answers  


define function

4 Answers   Assurgent, Sonata,


What is static volatile in c?

0 Answers  


What does the error message "DGROUP exceeds 64K" mean?

0 Answers   Celstream,


What is calloc in c?

0 Answers  


What is a memory leak? How to avoid it?

1 Answers  


What are the advantage of c language?

0 Answers  


Categories