#include<stdio.h>
int string_reverse(int l,char s[])
{ int i=0;
int j=l-1;
int t;
while(i<j)
{
t=s[i];
s[i]=s[j];
s[j]=t;
i++;
j--;
}
return s;
}
int string_length(char s[])
{
int j=0;
while(s[j]!='\0')
{
j++;
}
return j;
}
int main()
{
char a[100],t;
int l;
printf("Enter a string\n");
gets(a);
l=string_length(a);
string_reverse(l,a);
printf("The reversed string is: ");
puts(a);
}
Note: Need to be arranged in compiler after copied
OutPut:
Enter a string EVIL The reversed string is: LIVE