-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorrect.c
More file actions
83 lines (75 loc) · 1.08 KB
/
correct.c
File metadata and controls
83 lines (75 loc) · 1.08 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "main.h"
/**
*_eputs - it prints input
* @str: its str
*
* Return: it returns Nothing
*/
void _eputs(char *str)
{
int c = 0;
if (!str)
return;
while (str[c] != '\0')
{
_eputchar(str[c]);
c++;
}
}
/**
* _eputchar - it writes the character
* @c: charac
*
* Return: On success 1 and -1 on error
*/
int _eputchar(char c)
{
static int d;
static char buf[WRITE_BUF_SIZE];
if (c == BUF_FLUSH || d >= WRITE_BUF_SIZE)
{
write(2, buf, d);
d = 0;
}
if (c != BUF_FLUSH)
buf[d++] = c;
return (1);
}
/**
* _putfd - it writes the char c given fd
* @c: char
* @fd:filedescrip
*
* Return: On success 1.
*/
int _putfd(char c, int fd)
{
static int d;
static char buf[WRITE_BUF_SIZE];
if (c == BUF_FLUSH || d >= WRITE_BUF_SIZE)
{
write(fd, buf, d);
d = 0;
}
if (c != BUF_FLUSH)
buf[d++] = c;
return (1);
}
/**
*_putsfd - it prints str
* @str: string to printed
* @fd: its filedescripto
*
* Return: its num of char
*/
int _putsfd(char *str, int fd)
{
int d = 0;
if (!str)
return (0);
while (*str)
{
d += _putfd(*str++, fd);
}
return (d);
}