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 |
Can you please explain the difference between strcpy() and memcpy() function?
Why use int main instead of void main?
How to set a variable in the environment list?
How many types of operators are there in c?
What is function and its example?
How to add two numbers without using semicolon n c????
if the address of a[1,1] and a[2,1] are 1000 and 1010 respectively and each occupies 2 bytes then the array has been stored in what order?
4 Answers Amazon, Apple, Bata, Google, NASA,
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
When is the “void” keyword used in a function?
Write a program to print factorial of given number using recursion?
Can you think of a way when a program crashed before reaching main? If yes how?
Can a variable be both static and volatile in c?