diff options
Diffstat (limited to 'rushs/tinyprintf/str_revert')
| -rw-r--r-- | rushs/tinyprintf/str_revert/str_revert.c | 25 | ||||
| -rw-r--r-- | rushs/tinyprintf/str_revert/str_revert.h | 6 |
2 files changed, 31 insertions, 0 deletions
diff --git a/rushs/tinyprintf/str_revert/str_revert.c b/rushs/tinyprintf/str_revert/str_revert.c new file mode 100644 index 0000000..31f7f3d --- /dev/null +++ b/rushs/tinyprintf/str_revert/str_revert.c @@ -0,0 +1,25 @@ +#include "str_revert.h" + +#include <stddef.h> + +void str_revert(char str[]) +{ + if (*str == '\0') + { + return; + } + + size_t len = 0; + for (; str[len]; len++) + { + continue; + } + len--; + + for (size_t i = 0; i <= len / 2; i++) + { + char tmp = str[i]; + str[i] = str[len - i]; + str[len - i] = tmp; + } +} diff --git a/rushs/tinyprintf/str_revert/str_revert.h b/rushs/tinyprintf/str_revert/str_revert.h new file mode 100644 index 0000000..daa23d4 --- /dev/null +++ b/rushs/tinyprintf/str_revert/str_revert.h @@ -0,0 +1,6 @@ +#ifndef STR_REVERT_H +#define STR_REVERT_H + +void str_revert(char str[]); + +#endif /* ! STR_REVERT_H */ |
