my_evil_str.c


SUBMITTED BY: Guest

DATE: Nov. 29, 2013, 6:38 p.m.

FORMAT: Text only

SIZE: 721 Bytes

HITS: 3639

  1. int my_strlen(char *str)
  2. {
  3. int nb;
  4. nb = 0;
  5. while (str[nb] != '\0')
  6. {
  7. nb = nb + 1;
  8. }
  9. return nb;
  10. }
  11. int my_putstr(char *str)
  12. {
  13. int nb;
  14. nb = 0;
  15. while (str[nb] != 0)
  16. {
  17. my_putchar(str[nb]);
  18. nb = nb + 1;
  19. }
  20. }
  21. char *my_evil_str(char *str)
  22. {
  23. int start;
  24. int max;
  25. int mid;
  26. char save;
  27. start = 0;
  28. max = my_strlen(str);
  29. mid = max / 2;
  30. max = max - 1;
  31. while (start < mid)
  32. {
  33. save = str[start];
  34. str[start] = str[max];
  35. str[max] = save;
  36. start = start + 1;
  37. max = max - 1;
  38. }
  39. }

comments powered by Disqus