From 4b178c0feb4c415be36be0e4c0def8c447ed42af Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 22 Nov 2019 22:17:54 +0100 Subject: Added the most awesome c lib --- src/mlibc/string/strinv.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/mlibc/string/strinv.c (limited to 'src/mlibc/string/strinv.c') diff --git a/src/mlibc/string/strinv.c b/src/mlibc/string/strinv.c new file mode 100644 index 0000000..c6dd7fd --- /dev/null +++ b/src/mlibc/string/strinv.c @@ -0,0 +1,12 @@ +#include + +void strinv(char *str) { + size_t s_str = strlen(str); + + int iterations = (int) s_str / 2; + for (int i = 0; i < iterations; i++) { + char aux = str[i]; + str[i] = str[(s_str - i) - 1]; + str[(s_str - i) - 1] = aux; + } +} \ No newline at end of file -- cgit v1.2.3