-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv_print.c
More file actions
39 lines (36 loc) · 1.35 KB
/
v_print.c
File metadata and controls
39 lines (36 loc) · 1.35 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* v_print.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: glegendr <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/21 16:28:18 by glegendr #+# #+# */
/* Updated: 2019/11/28 19:29:51 by glegendr ### ########.fr */
/* */
/* ************************************************************************** */
#include "vector.h"
#include <unistd.h>
void v_print(t_vec *vec)
{
int i;
i = 0;
v_putchar('{');
if (v_get_size(vec) == sizeof(char))
write(1, v_get(vec, 0), vec->private_elem_nb);
else if (v_get_size(vec) == sizeof(int))
while (i < v_size(vec))
{
v_putnbr(*(int *)v_get(vec, i));
++i;
if (i < v_size(vec))
v_putchar(' ');
}
else if (v_get_size(vec) == sizeof(t_vec))
while (i < v_size(vec))
{
v_print(v_get(vec, i));
++i;
}
v_putchar('}');
}