Skip to content

Commit 3d5637d

Browse files
committed
added: 3-puts
1 parent 47e8803 commit 3d5637d

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

0x05-pointers_arrays_strings/3-main.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "main.h"
2+
3+
/**
4+
* main - check the code
5+
*
6+
* Return: Always 0.
7+
*/
8+
int main(void)
9+
{
10+
char *str;
11+
12+
str = "I do not fear computers. I fear the lack of them - Isaac Asimov";
13+
_puts(str);
14+
return (0);
15+
}

0x05-pointers_arrays_strings/3-puts.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "main.h"
2+
3+
/**
4+
* _puts - print string to stdout.
5+
*
6+
* @str: string to be printed.
7+
*
8+
* Return: Nothing.
9+
*/
10+
void _puts(char *str)
11+
{
12+
char *ptr;
13+
14+
ptr = str;
15+
while (*ptr != '\0')
16+
{
17+
_putchar(*ptr);
18+
ptr = ptr + 1;
19+
}
20+
_putchar('\n');
21+
}

0x05-pointers_arrays_strings/main.h

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ int _putchar(char);
22
void reset_to_98(int *);
33
void swap_int(int *, int *);
44
int _strlen(char *);
5+
void _puts(char *);

0 commit comments

Comments
 (0)