-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_put.c
More file actions
39 lines (34 loc) · 681 Bytes
/
Copy path_put.c
File metadata and controls
39 lines (34 loc) · 681 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
#include "main.h"
/**
* _puts - Prints a string with a newline character.
* @str: The string to be printed.
*
* Return: Returns the number of characters printed.
*/
int _puts(char *str)
{
char *a = str;
while (*str)
_putchar(*str++);
return (str - a);
}
/**
* _putchar - Writes the character 'c' to the standard output (stdout).
* @c: The character to be printed.
*
* Return: On success, returns 1.
* On error, returns -1, and sets errno appropriately.
*/
int _putchar(int c)
{
static int i;
static char buf[OUTPUT_BUF_SIZE];
if (c == BUF_FLUSH || i >= OUTPUT_BUF_SIZE)
{
write(1, buf, i);
i = 0;
}
if (c != BUF_FLUSH)
buf[i++] = c;
return (1);
}