Advertisement
horselurrver

Ch11 Ex8

Aug 10th, 2016
284
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 <string.h>
  3.  
  4. char *reverse(char *string);
  5. int main(void){
  6.     char phrase[]="yuppers";
  7.     printf("%s", reverse(phrase));
  8.     printf("\n");
  9.     return 0;
  10. }
  11.  
  12. char *reverse(char *string){
  13.     int j=(int)strlen(string)-1;
  14.     char temp;
  15.     int i=0;
  16.     while(i<j){
  17.         temp=string[i];
  18.         string[i]=string[j];
  19.         string[j]=temp;
  20.         i++;
  21.         j--;
  22.  
  23.     }
  24.     return string;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement