glenjoy
Banned
- Joined
- Jan 1, 2004
- Messages
- 962
- Helped
- 72
- Reputation
- 146
- Reaction score
- 20
- Trophy points
- 1,298
- Location
- Philippines
- Activity points
- 0
I encountered this prblem in the book C How to program, and too bad, there is no clear explanation how this happened.
Here is the code:
Can someone explain me how the code works, by dissecting it, thanks.
Here is the code:
Code:
#include <stdio.h>
int main()
{
char sentence[80];
void reverse(const char * const);
printf("Enter a line of text:\n");
gets(sentence);
printf("\nThe line printed backwards is:\n");
reverse(sentence);
return 0;
}
void reverse(const char * const sPtr)
{
if(sPtr[0] == '\0')
return;
else
{
reverse(&sPtr[1]);
putchar(sPtr[0]);
}
}
Can someone explain me how the code works, by dissecting it, thanks.