質問編集履歴
3
ソースコードの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -35,7 +35,6 @@
|
|
35
35
|
void ft_list_push_front(t_list **begin_list, void *data)
|
36
36
|
{
|
37
37
|
t_list *ndptr;
|
38
|
-
t_list *head;
|
39
38
|
|
40
39
|
ndptr = ft_create_elem(data);
|
41
40
|
if (ndptr != NULL)
|
2
ソースコード
title
CHANGED
File without changes
|
body
CHANGED
@@ -44,4 +44,30 @@
|
|
44
44
|
*begin_list = ndptr;
|
45
45
|
}
|
46
46
|
}
|
47
|
+
|
48
|
+
void listPrint(t_list *list)
|
49
|
+
{
|
50
|
+
while (list != NULL)
|
51
|
+
{
|
52
|
+
printf("%d\n",*(int*)list->data);
|
53
|
+
list = list->next;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
int main()
|
58
|
+
{
|
59
|
+
t_list *list;
|
60
|
+
int i;
|
61
|
+
|
62
|
+
i = 10;
|
63
|
+
list = NULL;
|
64
|
+
while (i <= 30)
|
65
|
+
{
|
66
|
+
ft_list_push_front(&list,&i);
|
67
|
+
i += 10;
|
68
|
+
}
|
69
|
+
listPrint(list);
|
70
|
+
|
71
|
+
return 0;
|
72
|
+
}
|
47
73
|
```
|
1
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,8 +6,6 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
```ここに言語を入力c
|
9
|
-
コード
|
10
|
-
```
|
11
9
|
#include <stdlib.h>
|
12
10
|
#include <stdio.h>
|
13
11
|
|
@@ -17,11 +15,11 @@
|
|
17
15
|
void *data;
|
18
16
|
} t_list;
|
19
17
|
|
20
|
-
t_list *
|
18
|
+
t_list *ft_create_elem(void *data)
|
21
19
|
{
|
22
20
|
t_list *list;
|
23
21
|
|
24
|
-
list = (t_list*)malloc(sizeof(t_list));
|
22
|
+
list = (t_list*)malloc(sizeof(t_list)); //listにt_listのサイズを確保
|
25
23
|
if (list == NULL)
|
26
24
|
{
|
27
25
|
return NULL;
|
@@ -37,38 +35,13 @@
|
|
37
35
|
void ft_list_push_front(t_list **begin_list, void *data)
|
38
36
|
{
|
39
37
|
t_list *ndptr;
|
38
|
+
t_list *head;
|
40
39
|
|
41
|
-
ndptr =
|
40
|
+
ndptr = ft_create_elem(data);
|
42
41
|
if (ndptr != NULL)
|
43
42
|
{
|
44
43
|
ndptr->next = *begin_list;
|
45
44
|
*begin_list = ndptr;
|
46
45
|
}
|
47
46
|
}
|
48
|
-
|
49
|
-
void listPrint(t_list *list)
|
50
|
-
{
|
51
|
-
while (list != NULL)
|
52
|
-
{
|
53
|
-
printf("%d\n",*(int*)list->data);
|
54
|
-
list = list->next;
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
int main()
|
59
|
-
{
|
60
|
-
t_list *list;
|
61
|
-
|
47
|
+
```
|
62
|
-
|
63
|
-
i = 10;
|
64
|
-
list = NULL;
|
65
|
-
while (i <= 30)
|
66
|
-
{
|
67
|
-
ft_list_push_front(&list,&i);
|
68
|
-
i += 10;
|
69
|
-
}
|
70
|
-
listPrint(list);
|
71
|
-
|
72
|
-
return 0;
|
73
|
-
}
|
74
|
-
|