Reverse a string

Nov 3, 2014 at 4:47pm
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.
Nov 3, 2014 at 4:57pm
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?
Nov 3, 2014 at 7:10pm
I've got just a bit idea about them but still cant understand the program.

I am familair with recursive functions.
Last edited on Nov 3, 2014 at 7:11pm
Topic archived. No new replies allowed.