본문내용
#include
#include
struct selfref
{
int n;
struct selfref *next;
};
typedef struct selfref list;
int main(void)
{
list *first = NULL, *second = NULL, *third = NULL, *middle = NULL;
first = (list *) malloc(sizeof(list));
first->n = 100;
second = (list *) malloc(sizeof(list));
second->n = 200;
third = (list *) malloc(sizeof(list));
third->n = 300;
middle = (list *) malloc(sizeof(list));
middle->n = 150;
/*
first->next = second;
second->next = third;
third->next = NULL;
middle->next = second;
first->next = middle;
middle->next = third;
*/
first->next = second;
second->next = third;
third->next = NULL;
middle->next = second;
first->next = middle;
printf("첫번째 구조체 >> \n");
printf("\t 자료 값(first->n) = %d", first->n);
printf("\t 자료의 주소값(first) = %#X \n\n", first);
#include
struct selfref
{
int n;
struct selfref *next;
};
typedef struct selfref list;
int main(void)
{
list *first = NULL, *second = NULL, *third = NULL, *middle = NULL;
first = (list *) malloc(sizeof(list));
first->n = 100;
second = (list *) malloc(sizeof(list));
second->n = 200;
third = (list *) malloc(sizeof(list));
third->n = 300;
middle = (list *) malloc(sizeof(list));
middle->n = 150;
/*
first->next = second;
second->next = third;
third->next = NULL;
middle->next = second;
first->next = middle;
middle->next = third;
*/
first->next = second;
second->next = third;
third->next = NULL;
middle->next = second;
first->next = middle;
printf("첫번째 구조체 >> \n");
printf("\t 자료 값(first->n) = %d", first->n);
printf("\t 자료의 주소값(first) = %#X \n\n", first);