Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- int ft_strlen(char *string)
- {
- int i;
- i = 0;
- if (!string || !*string)
- return (0);
- while (string[i])
- ++i;
- return (i);
- }
- char *ft_strrev(char *string)
- {
- int Acounter;
- int Bcounter;
- char temp[ft_strlen(string) + 1];
- Acounter = 0;
- Bcounter = 0;
- if (!string || !*string)
- return (string);
- while (string[Acounter])
- Acounter++;
- while (Acounter > 0)
- {
- Acounter--;
- temp[Bcounter++] = string[Acounter];
- }
- while (Bcounter-- > 0)
- {
- (string[Acounter] = temp[Acounter]);
- Acounter++;
- }
- return (string);
- }
- int main(void)
- {
- char string[27] = "Death to the false emperor";
- printf ("result = %s", ft_strrev(string));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement