aboutsummaryrefslogtreecommitdiff
path: root/c02/ex01/ft_strncpy.c
diff options
context:
space:
mode:
Diffstat (limited to 'c02/ex01/ft_strncpy.c')
-rw-r--r--c02/ex01/ft_strncpy.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/c02/ex01/ft_strncpy.c b/c02/ex01/ft_strncpy.c
new file mode 100644
index 0000000..61bb451
--- /dev/null
+++ b/c02/ex01/ft_strncpy.c
@@ -0,0 +1,29 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strncpy.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/03 19:02:31 by cacharle #+# #+# */
+/* Updated: 2019/07/03 19:36:32 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+char *ft_strncpy(char *dest, char *src, unsigned int n)
+{
+ int i;
+
+ i = 0;
+ while (i < n || src[i] != '\0')
+ {
+ dest[i] = src[i];
+ i++;
+ }
+ while (i < n)
+ {
+ dest[i] = '\0';
+ i++;
+ }
+ return (dest);
+}