Advertisement
apl-mhd

StringReverse

Oct 28th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1.  
  2. #include<stdio.h>
  3. #include<string.h>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.  
  8.     int i = 0, j;
  9.     char str[50], temp;
  10.  
  11.     gets(str);
  12.  
  13.     j = strlen(str) - 1;
  14.  
  15.     printf("%d ", j);
  16.  
  17.     while( i < j ){
  18.  
  19.         temp = str[i];
  20.         str[i] = str[j];
  21.         str[j] = temp;
  22.  
  23.         i++;
  24.         j--;
  25.     }
  26.  
  27.     printf(" %s ", str);
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement