Why is the code below functioning. According to me it MUST
NOT.
Answer / h0rryp0tter
Please have a look at the code below :
char str[1];
int i = 0;
void revstr(void);
int main(void)
{
revstr();
printf("%s\n",str);
return 0;
}
void revstr(void)
{
char c = getchar();
if (c!= EOF) {
revstr();
str[i++] = c;
}
str[i] = '\0';
}
Written using Bloodshed Dev C++.
I am trying to access and write on an char array which has
been defined with only one element in it. The above code
must give me Errors of some kind. But on the contrary, it
works.
| Is This Answer Correct ? | 0 Yes | 1 No |
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
What is the use of getchar() function?
How to reverse a string using a recursive function, without swapping or using an extra memory?
31 Answers Cisco, Mind Tree, Motorola, Ophio, Sony, TCS, Wipro,
Explain how does free() know explain how much memory to release?
How do you write a program which produces its own source code as its output?
Which is more efficient, a switch statement or an if else chain?
In which language linux is written?
Find greatest number out of 10 number without using loop.
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 "); }
what are the static variables
8 Answers HCL, iFlex, TCS, Wipro,
swapping of two numbers without using third variable using AND and OR operators
difference of two no's with out using - operator