String Reverse using temp
#include <stdio.h>
#include <string.h>
int main() {
char str[20];
char temp;
int i = 0;
int j = 0;
int strlength = 0;
printf ("Enter string to reverse ");
scanf ("%s", str);
strlength = strlen(str);
for (i = 0, j = strlength - 1; i < strlength / 2; i++, j--) {
temp = str[i];
str[i] = str[j];
str[j] = temp;
}
printf (" Reversed string is : %s\n", str);
return 0;
}
Comments
Post a Comment