what will be the result of the following program ?
char *gxxx()
{
static char xxx[1024];
return xxx;
}
main()
{
char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is :
%s",gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these
Answers were Sorted based on User's Feedback
Answer / jaya prakash
b) The String is :OldString
Because ,for Static var memory is only one time created.
Eventhough the fn is multiple times called,
so
consider addr of xxx is 4444,
first strcpy copy the string "string" to addr 4444,
then g=4444;
then oldstring overwrites to location 4444.
Is This Answer Correct ? | 8 Yes | 0 No |
write a program for fibonaci series by using while loop in c?
what is output? main() { #define SQR(x) x++ * ++x int i = 3; printf(" %d %d ",SQR(i),i * SQR(i)); } a)9 27 b)35 60 c)20 60 d)15 175
Explain the concept and use of type void.
Can a pointer point to null?
How to receive strings with spaces in scanf()
write the program for maximum of the following numbers? 122,198,290,71,143,325,98
Explain what is a const pointer?
What is bubble sort in c?
why programs in c are running with out #include<stdio.h>? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }
Write a program to print distinct words in an input along with their count in input in decreasing order of their count
count the numbers between 100 and 300, that star with 2 and ends with 2
What will be printed as the result of the operation below: #include<..> int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x); }