Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4.  
  5. char* reverse(char*);
  6.  
  7.  
  8. int main(void) {
  9.  
  10. char s[] = "abcdefghijklmnopqrstuvwxyz";
  11. printf("%s",reverse(s));
  12. return 0;
  13. }
  14.  
  15. char* reverse(char* string){
  16. int length = strlen(string);
  17. int limit = (int)floor(length/2);
  18. printf("%d \n",limit);
  19. char temp;
  20.  
  21. for(int x = 0;x<limit;x++){
  22.  
  23. temp = string[x];
  24. string[x] = string[length-x-1];
  25. string[length-x-1] = temp;
  26.  
  27. }
  28.  
  29. return string;
  30.  
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement