Reverse a string

Explain this program to reverse an input string:
#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
void reverse(void);
clrscr();
reverse();
getch();
}

void reverse(void)
{
char x;
if((x=getchar())!= '\n')
{
reverse();
}
putchar(x);
}

Do not assume i know about getchar and putchar.
Do not assume i know about getchar and putchar.

Why not? You can easily look them up, so there's no need to explain them to you.

Are you familiar with recursive functions?
I've got just a bit idea about them but still cant understand the program.

I am familair with recursive functions.
Last edited on
Topic archived. No new replies allowed.