-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.c
70 lines (61 loc) · 1.5 KB
/
utils.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jschotte <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/12/18 14:40:05 by jschotte #+# #+# */
/* Updated: 2015/12/18 15:30:18 by jschotte ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
#include <unistd.h>
#include <stdlib.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}
int ft_isalpha(int c)
{
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
return (1);
else
return (0);
}
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
{
ft_putchar(str[i]);
i++;
}
}
void *ft_memalloc(size_t size)
{
char *str;
size_t i;
i = 0;
str = malloc(size);
if (str == NULL)
return (NULL);
else
{
while (i < size)
{
str[i] = 0;
i++;
}
return (str);
}
}
size_t ft_strlen(const char *s)
{
size_t count;
count = 0;
while (s[count] != '\0')
count++;
return (count);
}