diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
| commit | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch) | |
| tree | 3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /rushs/tinyprintf/str_revert/str_revert.c | |
add: graphs et rushs
Diffstat (limited to 'rushs/tinyprintf/str_revert/str_revert.c')
| -rw-r--r-- | rushs/tinyprintf/str_revert/str_revert.c | 25 |
1 files changed, 25 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; + } +} |
