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
Why string is used in c?
Explain the concept and use of type void.
What is New modifiers?
How can my program discover the complete pathname to the executable from which it was invoked?
Explain what’s a signal? Explain what do I use signals for?
Can include files be nested? How many levels deep can include files be nested?
How to declare pointer variables?
Explain how can you restore a redirected standard stream?
Is c call by value?
Array is an lvalue or not?
What is double pointer?
What are the 5 organizational structures?
Are comments included during the compilation stage and placed in the EXE file as well?
What is the scope of global variable in c?
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?