Advertisement
rafikamal

String Reverse

Jan 23rd, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void stringReverse(char str1[]);
  5.  
  6. int main()
  7. {
  8.     char s1[] = "BUET";
  9.  
  10.     stringReverse(s1);
  11.  
  12.     printf(s1);
  13.  
  14.     return 0;
  15. }
  16.  
  17. void stringReverse(char str[])
  18. {
  19.     char temp[100];
  20.     int len = strlen(str), i;
  21.  
  22.     for(i = 0; str[i] != '\0'; i++)
  23.         temp[len - i - 1] = str[i];
  24.     temp[i] = '\0';
  25.  
  26.     strcpy(str, temp);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement