summaryrefslogtreecommitdiffstats
path: root/libft/main.c
blob: d0cacd5f00fefb75adb5c4ba7b4592a9a0a60821 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "libft.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <limits.h>
#include <inttypes.h>

/*
** static void
** putlst(t_list *lst, t_list *init)
** {
** 	uint8_t i;
** 
** 	i = 0;
** 	printf("list:\n");
** 	while (lst != NULL)
** 	{
** 		printf("lst[%d] (%s)\n", i, (char*)lst->content);
** 		lst = lst->next;
** 		i++;
** 	}
** 	lst = init;
** }
** 
** static void
** delfunc(void *content)
** {
** 	free(content);
** }
** 
** #include <unistd.h>
** int main(void) {
**  	t_list *lst  = NULL;
**  	t_list *init = NULL;
**  
**  	char *c0;
**  	char *c1;
**  	char *c2;
**  	char *c3;
**  	char *c4;
**  	char *c5;
**  	char *c6;
**  	char *c7;
**  
**  	c0 = (char *)ft_calloc(6, sizeof(char));
**  	c1 = (char *)ft_calloc(6, sizeof(char));
**  	c2 = (char *)ft_calloc(6, sizeof(char));
**  	c3 = (char *)ft_calloc(6, sizeof(char));
**  	c4 = (char *)ft_calloc(6, sizeof(char));
**  	c5 = (char *)ft_calloc(6, sizeof(char));
**  	c6 = (char *)ft_calloc(6, sizeof(char));
**  	c7 = (char *)ft_calloc(6, sizeof(char));
**  	if (!c0 || !c1 || !c2 || !c3 || !c4 || !c5 || !c6 || !c7)
**  		return 1;
**  	memcpy(c0, "first", 6);
**  	memcpy(c1, "secon", 6);
**  	memcpy(c2, "third", 6);
**  	memcpy(c3, "fooba", 6);
**  	memcpy(c4, "qweqw", 6);
**  	memcpy(c5, "AAAAA", 6);
**  	memcpy(c6, "front", 6);
**  	memcpy(c7, "_back", 6);
**  
**  	// INIT
**  	printf("INIT\n");
**  	lst = ft_lstnew(c0);
**  	init = lst;
**  	lst->next = ft_lstnew(c1);
**  	lst = lst->next;
**  	lst->next = ft_lstnew(c2);
**  	lst = lst->next;
**  	lst->next = ft_lstnew(c3);
**  	lst = lst->next;
**  	lst->next = ft_lstnew(c4);
**  	lst = lst->next;
**  	lst->next = ft_lstnew(c5);
**  	lst = lst->next;
**  	lst = init;
**  	putlst(lst, init);
**  
*/ 	/* ADD FRONT */
/* 	printf("\n\nft_lstadd_front\n");
** 	ft_lstadd_front(&lst, ft_lstnew(c6));
** 	putlst(lst, init);
** 
*/ 	/* ADD BACK */
/* 	printf("\n\nft_lstadd_back\n");
** 	ft_lstadd_back(&lst, ft_lstnew(c7));
** 	putlst(lst, init);
** 
*/  	/* DELONE */
/* 	printf("\n\nft_lstdelone\n");
**  	ft_lstdelone(lst->next->next, &delfunc);
**  	putlst(lst, init);
** 	lst->next->next = ft_lstnew(c3);
** 
*/ 	/* CLEAR */
/* 	printf("\n\nft_lstclear\n");
**  	ft_lstclear(&lst, &delfunc);
** 	putlst(lst, init);
** 
** 	char dst[40] = "foo";
** 	char src[40] = "foo";
** 	size_t len = 4;
** 	printf("%s\n", ft_strnstr(dst, src, len));
** 	return 0;
** }
*/

int main(void) {
	char   dst[40] = "bar";
	char   src[40] = "Foobar";

	char   dst2[40] = "bar";
	char   src2[40] = "Foobar";

	size_t len     = 8;
	printf("FT_RETURN (%s)\n", ft_memmove(dst, src, len));
	printf("C__RETURN (%s)\n",    memmove(dst2, src2, len));
	return (0);
}