Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- int ft_strlen(char *str)
- {
- int c;
- c = 0;
- while (str[c] != 0)
- {
- c++;
- }
- return (c);
- }
- char *ft_strdup(char *src)
- {
- char *dst;
- int a;
- int run;
- run = 0;
- a = ft_strlen(src);
- dst = (char*)malloc(sizeof(char) * a);
- while (run != a)
- {
- dst[run] = src[run];
- run++;
- }
- dst[run] = '\0';
- return (dst);
- }
- int main()
- {
- char *hui;
- hui = "sosipidaraz";
- printf("%s", ft_strdup(hui));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment