-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic_functions.c
More file actions
51 lines (44 loc) · 769 Bytes
/
basic_functions.c
File metadata and controls
51 lines (44 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "holberton.h"
#include <unistd.h>
#include <stdio.h>
/**
* _puts - Function that prints a string, follow by a new line.
* @str: Pointer of the string str.
* Return: 0
*/
int _puts(char *str)
{
int l = 0;
while (str[l] != '\0')
{
_putchar(str[l]);
l++;
}
return (l - 1);
}
/**
* _putchar - Writes the character c to stdout.
* @c: The type character to print.
*
* Return: On success 1.
* On error, -1 is returned, and error is set appropriately.
*/
int _putchar(char c)
{
return (write(1, &c, 1));
}
/**
* _strlen - Length of a string.
* @s: char array pointer.
* Return: On success 1.
* On error, -1 is returned, and error is set appropriately.
*/
int _strlen(char *s)
{
int i;
while (s[i] != '\0')
{
i++;
}
return (i);
}