/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strncpy.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tischmid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/03/19 10:25:26 by tischmid #+# #+# */ /* Updated: 2023/03/24 01:29:37 by tischmid ### ########.fr */ /* */ /* ************************************************************************** */ char *ft_strncpy(char *dest, char *src, unsigned int n) { ++n; while (--n && *src) *dest++ = *src++; while (n--) *dest++ = 0; return (dest); } /* //// #include #define BUFSIZE 10 #define STR "||||||||||" int main(void) { char buf[BUFSIZE] = STR; for (int j = 0; j < 11; ++j) { printf("####### Size == %d #######\n", j); ft_strncpy(buf, "Hei", j); for (int i = 0; i < BUFSIZE; ++i) printf((buf[i] >= 32 && buf[i] <= 126) ? "%c\n" : "0x%x\n", buf[i]); } return (0); } */ ////