Hi, I had just written a programme which reverses a sentence whatever the user gives. for eg:If the user gives the sentence as "How are you",my programm generates "uoy era woH". The programme which i had written is shown below.I just have a wild intution that there can be a smarter programe than the one which i had written.So valuable inputs from your side is most appreciated or any better programme than this is also most welcome.
int ReverseString(char *);
main()
{
char *Str;
printf("enter any string\n");
gets(Str);
ReverseString(Str);
getch();
}
int ReverseString(char *rev)
{
int len = 0;
char p;
while(*rev!='\0')
{
len++;
rev++;
}
rev--;
while(len>0)
{
p = *rev;
putchar(p);
rev--;
len--;
}
}
Thanks a lot