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

Answer Posted / abhisheksingh462

Answer is "second string" because both handle same address

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none

648


Explain the difference between the local variable and global variable in c?

605


Explain is it valid to address one element beyond the end of an array?

736


Explain what are bus errors, memory faults, and core dumps?

792


What is the difference between union and structure in c?

579






write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...

1489


What is array of pointers to string?

570


Why does everyone say not to use scanf? What should I use instead?

682


What is string function in c?

541


which is conditional construct a) if statement b) switch statement c) while/for d) goto

740


#include int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20

1267


Why c is a procedural language?

585


Does sprintf put null character?

604


What are structural members?

574


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

625