• Source
    1. #include <stdio.h>
    2. #include <string.h>
    3.  
    4. void swapstring( char temp_str[] )
    5. {
    6. int str_len = strlen(temp_str);
    7. int start = 0;
    8. int end = str_len - 1;
    9. char temp_char;
    10.  
    11. while( start < end )
    12. {
    13. temp_char = temp_str[end];
    14. temp_str[end] = temp_str[start];
    15. temp_str[start] = temp_char;
    16.  
    17. start++;
    18. end--;
    19. }
    20. }
    21.  
    22. int main(void) {
    23. // your code goes here
    24. unsigned char temp_str[] = "hello world";
    25. printf("Original string : %s \n", temp_str);
    26. swapstring(temp_str);
    27. printf("Swaped string : %s \n", temp_str);
    28.  
    29. return 0;
    30. }
    31.