Advertisement
bkit4s0

[reverse string]

Jan 1st, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4. void reversestring(char s1[], char s2[])
  5. {
  6.     int l = strlen(s1);
  7.     int i;
  8.     for (i = 0; i < l; ++i)
  9.     {
  10.         s2[i] = s1[l-i-1];
  11.     }
  12.     s2[i] = '\0';
  13. }
  14. int main(int argc, char const *argv[])
  15. {
  16.     char s1[] = "tran trung vi";
  17.     char s2[100];
  18.     //clrscr();
  19.     //printf("Nhap vao chuoi ki tu\n");
  20.     //scanf("%s",s1);
  21.    
  22.     reversestring(s1,s2);
  23.     puts(s2);
  24.     system("pause");
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement