We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9b014ee commit 4499af0Copy full SHA for 4499af0
0x06-pointers_arrays_strings/2-strncpy.c
@@ -0,0 +1,36 @@
1
+#include "main.h"
2
+
3
+/**
4
+ * _strncpy - A function that copies a string.
5
+ *
6
+ * @dest: The destination string
7
+ * @src: The string to copy
8
+ * @n: Number of times to copy
9
10
+ * Return: The copy of the src and append it to the dest
11
+ * n number of times.
12
+ */
13
14
+char *_strncpy(char *dest, char *src, int n)
15
+{
16
+ int join = 0, i = 0;
17
18
+ while (src[i])
19
+ {
20
+ i++;
21
+ }
22
23
+ while (join < n && src[join])
24
25
+ dest[join] = src[join];
26
+ join++;
27
28
29
+ while (join < n)
30
31
+ dest[join] = '\0';
32
33
34
35
+ return (dest);
36
+}
0 commit comments