File tree 2 files changed +38
-0
lines changed
2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include "holberton.h"
2
+ #include <stdlib.h>
3
+
4
+ /**
5
+ * create_array - creates an array and initializes with specific character
6
+ * @size: is the size of the array to be created
7
+ * @c: character with the one to be initialized
8
+ *
9
+ * Return: a pointer to the to the created array, NULL if it fails
10
+ */
11
+
12
+ char * create_array (unsigned int size , char c )
13
+ {
14
+ char * ptr ;
15
+ int i = 0 ;
16
+
17
+ if (size == 0 )
18
+ return (NULL );
19
+
20
+ ptr = malloc (sizeof (char ) * size );
21
+
22
+ if (ptr == NULL )
23
+ return (NULL );
24
+
25
+ while (size -- )
26
+ {
27
+ ptr [i ++ ] = c ;
28
+ }
29
+
30
+ return (ptr );
31
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef HOLBERTON_H
2
+ #define HOLBERTON_H
3
+
4
+ int _putchar (char );
5
+ char * create_array (unsigned int , char );
6
+
7
+ #endif
You can’t perform that action at this time.
0 commit comments