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 to copy a string without using a string?
What the advantages of using Unions?
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
State the difference between realloc and free.
write a function which accept two numbers from main() and interchange them using pointers?
Tell me with an example the self-referential structure?
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
the number 138 is called well ordered number because the three digits in the number (1,3,8) increase from left to right (1<3<8). the number 365 is not well ordered coz 6 is larger than 5. write a program that wull find and display all possible three digit well ordered numbers. sample: 123,124,125,126,127,128,129,134 ,135,136,137,138,139,145,146,147 148 149,156.......789
4. main() { int c=- -2; printf("c=%d",c); }
Write a program that will read the input of any number of digits n in a row of shafh showing the breakdown of the printing and printing figures by the recursive function.
In C program, at end of the program we will give as "return 0" and "return 1", what they indicate? Is it mandatory to specify them?
write a program to count the no of repaeted words in a line?