I just wrote a program that cancels the sentence that the user gives. For example: if the user enters "Like you", my program generates "uoy era woH".
The program I wrote is shown below. I just have a wild intuition that there may be a smarter program than this. So your valuable contribution will be appreciated, or any better program than this is also very 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--;
}
}
Many thanks.
Maddy
source
share