-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmisc_functions2.c
More file actions
48 lines (42 loc) · 1.32 KB
/
misc_functions2.c
File metadata and controls
48 lines (42 loc) · 1.32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* misc_functions2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hmeftah <hmeftah@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/25 20:12:47 by hmeftah #+# #+# */
/* Updated: 2023/05/26 14:24:39 by hmeftah ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_malloc.h"
void print_str_with_int(char *string, unsigned int n)
{
print_string(string);
print_number(n);
write(1, "\n", 1);
}
void print_string(char *string)
{
int i;
i = 0;
while (string[i])
{
write(1, &string[i], 1);
i++;
}
}
void print_number(unsigned int number)
{
char n;
if (number >= 0 && number <= 9)
{
n = number + 48;
write(1, &n, 1);
}
else
{
print_number(number / 10);
print_number(number % 10);
}
}