fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void reverse(char *str)
  5. {
  6. if (!str || !(*str)) return;
  7.  
  8. char *end = str + strlen(str) - 1;
  9.  
  10. while (str < end) {
  11. char tmp = *str;
  12. *str++ = *end;
  13. *end-- = tmp;
  14. }
  15. }
  16.  
  17. int main(void)
  18. {
  19. char buffer[] = "hello";
  20. reverse(buffer);
  21. printf("%s",buffer);
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 4480KB
stdin
Standard input is empty
stdout
olleh