main.c

ft_stock_str.h

c08.ko.subject.pdf

C_08.pdf

✅ 헤더, 매크로함수, 구조체에 대한 이해와 활용

list의 이해 : 배열에 동적 할당을 하기 위해서 활용

[1, 2, 3, 5, 6] -> 추가할 수 없음
list[0] ...  계속 쓸 수 있음

동적 할당 /정적 할당 ?

typedef struct s_list
{
	struct s_list *next;
	int value;
} t_list

typedef int t; 

함수 (t_list **list,int ?)

**list로 넘길떄 &list로 주소 넘겨서 실행해야 값 변경 가능 
typedef struct s_node
{
	int	data;
	struct s_node *next;
}	t_node;

#include <stdlib.h>
#include <stdio.h>

void	print_node(t_node *ptr)
{
	while (ptr != 0)
	{list
		printf("%d ", ptr->data);
		ptr = ptr->next;
	}
}

t_node *make_node_tail(t_node *ptr)
{
	t_node *temp;

	if (ptr == 0)
	{
		ptr = (t_node *)malloc(sizeof(t_node));
		ptr->next = 0;
		ptr->data = 0;
		return (ptr);
	}
	temp = ptr;
	while (ptr->next != 0)
		ptr = ptr->next;
	ptr->next = (t_node *)malloc(sizeof(t_node));
	ptr->next->next = 0;
	ptr->next->data = 0;
	return (temp);
}

int	main(void)
{
	t_node *ptr;

	ptr = 0;
	ptr = make_node_tail(ptr);
	ptr->data = 980330;

	ptr = make_node_tail(ptr);
	ptr->next->data = 10614;// init 함수 만들기

	print_node(ptr);
	return (0);
}