-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
126 lines (113 loc) · 2.08 KB
/
main.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
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
123
124
125
126
#include "libft.h"
#include <stdio.h>
void ft_striteri_fun(unsigned int i, char *str)
{
char l;
i = 1;
if (*str >= 'a' && *str <= 'z')
{
l = *str;
*str = l - 32;
}
}
char ft_strmapi_fun(unsigned int i, char str)
{
i = 1;
str = 'M';
return (str);
}
void f_del(void *s)
{
free(s);
}
void ft_lstiter_fun(void *f)
{
char *e;
char d;
e = ft_calloc(13,1);
e = (char *)f;
while (*e)
{
d = *e;
*e = ft_toupper(d);
e++;
}
}
void *ft_lstmap_fun(void *f)
{
char *e;
char *t;
char d;
//e = ft_calloc(13,1);
e = (char *)f;
t = e;
while (*e)
{
if (*e >= 'a' && *e <= 'z')
{
d = *e;
*e = d - 32;
}
e++;
}
return (t);
}
int main()
{
char *s;
char *d;
char *l;
//char m;
s = ft_calloc(36,1);
d = ft_calloc(13,1);
l = ft_calloc(16,1);
//ft_bzero(s,13);
ft_memcpy(d,"test string",11);
ft_memcpy(l,"test1 stting1",15);
ft_memcpy(s,"--1-2--3---4----5-----42--54887--",36);
//ft_memset(d,'A',12);
// char **tab = ft_split(s,'-');
// while (*tab)
// printf("%s\n",*tab++);
//ft_striteri(d,&ft_striteri_fun);
//printf("%s\n",ft_strmapi(d,&ft_strmapi_fun));
//int i= -1;
// while (d[++i])
// {
// m = d[i];
// //ft_putchar_fd(m,1);
// d[i] = ft_toupper(m);
// //ft_putchar_fd(d[i],1);
// }
// printf("%s\n",d);
//ft_putnbr_fd(2147483647,1);
t_list *m;
t_list *temp;
t_list *mapilst;
m = ft_lstnew(ft_strdup("string1"));
m->next = ft_lstnew(ft_strdup("string2"));
ft_lstadd_back(&m,ft_lstnew(ft_strdup("string3")));
ft_lstadd_back(&m,ft_lstnew(ft_strdup("string4")));
temp = ft_lstlast(m);
ft_lstadd_front(&m,ft_lstnew(ft_strdup("string0")));
ft_lstadd_front(&m,ft_lstnew(ft_strdup("string")));
//ft_lstclear(&m, &f_del);
//ft_lstdelone(temp,free);
//ft_lstiter(m,&ft_lstiter_fun);
mapilst = ft_lstmap(m,&ft_lstmap_fun,&f_del);
printf("ft_lstlast |%s\n",temp->content);
// temp = m;
// while (temp != NULL)
// {
// printf("%s\n",temp->content);
// temp = temp->next;
// }
temp = mapilst;
while (temp != NULL)
{
printf("%s\n",temp->content);
temp = temp->next;
}
printf("ft_lstsize |%d\n",ft_lstsize(m));
return (0);
}