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 |
What is string length in c?
What are the different types of constants?
wt is d full form of c
What is typedef example?
Give the Output : * * * * * * * * * *
What is main return c?
main() { printf("hello"); fork(); }
which type of aspect you want from the student.
What is difference between %d and %i in c?
What is bss in c?
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
What is chain pointer in c?