diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-07-16 12:58:13 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-07-16 12:58:13 +0200 |
| commit | 14914f50c3de6c5444e13cf67db064b03c1c90ef (patch) | |
| tree | 3ecf5a41b4541980ba0287a431681cd5ae25ad84 /exam00/cacharle/ft_strrev | |
| parent | 217bcb0d4e3ba60604921cb40d5a11a64f93cfc7 (diff) | |
| download | piscine-14914f50c3de6c5444e13cf67db064b03c1c90ef.tar.gz piscine-14914f50c3de6c5444e13cf67db064b03c1c90ef.tar.bz2 piscine-14914f50c3de6c5444e13cf67db064b03c1c90ef.zip | |
c09 passed, c10 start, exam00 and exam01
Diffstat (limited to 'exam00/cacharle/ft_strrev')
| -rwxr-xr-x | exam00/cacharle/ft_strrev/ft_strrev.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/exam00/cacharle/ft_strrev/ft_strrev.c b/exam00/cacharle/ft_strrev/ft_strrev.c new file mode 100755 index 0000000..ef58887 --- /dev/null +++ b/exam00/cacharle/ft_strrev/ft_strrev.c @@ -0,0 +1,31 @@ +int ft_strlen(char *str) +{ + int counter; + + counter = 0; + while (*str) + { + counter++; + str++; + } + return (counter); +} + +char *ft_strrev(char *str) +{ + int i; + int j; + char tmp; + + i = 0; + j = ft_strlen(str) - 1; + while (i <= j) + { + tmp = str[i]; + str[i] = str[j]; + str[j] = tmp; + i++; + j--; + } + return (str); +} |
