#include <string.h> #include <conio.h> #include <stdio.h> void main() { int i,j,len=0; char str[50],revstr[50]; //clrscr(); printf("\n Enter a String to Reverse : " ); gets(str); for(i=0; str[i]!='\0'; i++) { len++; } j=0; for(i=len-1; i>=0; i--) { revstr[j++]=str[i]; } printf("\n Reverse of the Given String is: %s",revstr); free(str); getch(); }
OUTPUT:
Enter a String to Reverse : www.programming9.com Reverse of the Given String is: moc.9gnimmargorp.www