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 / kalyan chukka

The Answer is Second String

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why string is used in c?

583


Explain the concept and use of type void.

631


What is New modifiers?

672


How can my program discover the complete pathname to the executable from which it was invoked?

660


Explain what’s a signal? Explain what do I use signals for?

613






Can include files be nested? How many levels deep can include files be nested?

660


How to declare pointer variables?

687


Explain how can you restore a redirected standard stream?

593


Is c call by value?

607


Array is an lvalue or not?

641


What is double pointer?

560


What are the 5 organizational structures?

570


Are comments included during the compilation stage and placed in the EXE file as well?

672


What is the scope of global variable in c?

559


A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?

1512