-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_ft_itoa.c
52 lines (49 loc) · 1.67 KB
/
test_ft_itoa.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test_ft_itoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jliew <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/04 15:26:10 by jliew #+# #+# */
/* Updated: 2020/07/10 19:04:22 by jliew ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "libft.h"
int main(int argc, char **argv)
{
if (argc == 1)
{
printf("----------------------\n");
printf(" char *ft_itoa(int n)\n");
printf("----------------------\n");
printf("usage [auto]:\n");
printf("1. a --run\n");
printf("usage [manual]:\n");
printf("1. a <int n>\n");
}
else if (!strcmp(argv[1], "--run"))
{
int cases[] = {INT_MIN, INT_MAX, 0};
printf("----------------------\n");
printf(" char *ft_itoa(int n)\n");
printf("----------------------\n");
for (int i = 0; i < 3; i++)
{
char *ft = ft_itoa(cases[i]);
printf("[%i] n : %i, ft: %s\n", i + 1, cases[i], ft);
free(ft);
}
}
else
{
int n = atoi(argv[1]);
char *s = ft_itoa(n);
printf("ft: %s\n", s);
free(s);
printf("freed\n");
}
}