list_node는 이미 선언돼 있는거 아닌가요?
: : typedef struct list_node *list_pointer;
: : typedef struct list_node {
: : int data[4];
: : list_pointer link;
: : };
: : list_pointer ptr=NULL;
여기에서요.....???
: 답이 두군데나 있네요.
: C:workshoplist2.c(28) : error C2065: 'list_node' : undeclared identifier
: 하고..
: 주석에서 아주 자세히 설명하고 있는데... 질문은 왜하신건지...? -_-
:
:
:
:
: : C:workshoplist2.c(28) : error C2065: 'list_node' : undeclared identifier
: : 이런 에러가 뜨는데요..뭐가 잘못 된거지요?
: :
: :
: : #include <stdio.h>
: : #include <stdlib.h>
: : #include <stddef.h>
: :
: : typedef struct list_node *list_pointer;
: : typedef struct list_node {
: : int data[4];
: : list_pointer link;
: : };
: : list_pointer ptr=NULL;
: :
: : /* 위 선언은 자체참조구조(self-referential structure)의 예를 포함하고
: : 있다. struct(list_node)를 정의하기 전에 그 struct에 대한
: : 포인터(list_pointer)를 먼저 정의한다는 것에 주목하라. C는 아직
: : 존재하지 않는 타입에 대한 포인터의 생성을 지원하는데, 이는 그렇지
: : 않을 경우, 존재하지 않는 타입에 대한 포인터를 정의할 수 없다는
: : 사실과 새로운 타입을 정의하기 위해 그 타입에 대한 포인터를 포함해야
: : 한다는 사실 사이의 모순에 직면하기 때문이다. */
: :
: : #define IS_EMPTY(ptr) (!(ptr))
: : #define IS_FULL(ptr) (!(ptr))
: :
: :
: : void main(void)
: : {
: : list_pointer first, second;
: :
: : first=(list_pointer)malloc(sizeof(list_node));
: : second=(list_pointer)malloc(sizeof(list_node));
: :
: : second->link=NULL;
: : second->data=20;
: : first->data=10;
: : first->link=second;
: : printf("an integer = %d, a float = %f ", first->data, second->data);
: : free(second);
: : free(first);
: : }
: :
: : --
: : 서.명.
:
: --
: 원츄~!--서.명.