C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[38061] 헤더파일을 include 해주지 않아서 그런 걸까요?
서찬 [] 877 읽음    2004-11-16 21:03
linked list를 이용해서 다항식의 덧셈을 구현하고 하는데요.
아래와 같은 오류메시지가 출력됩니다.
이 구문에서 에러가 발생하는데요..
a = (poly_pointer)malloc(sizeof(poly_node));

poly_node는 분명히 정의를 해주었는데 왜 이런걸까요?
제가 혹시 뭔가 중요한 헤더파일을 빼먹고 있는 걸까요?
답변부탁드립니다.

#include <stdio.h>
#include <stdlib.h>
#define IS_FULL(ptr) (!(ptr))

typedef struct poly_node *poly_pointer;
typedef struct poly_node {
    int coef;
    int expon;
    poly_pointer link;
    };
poly_pointer a, b, d;

poly_pointer padd(poly_pointer a, poly_pointer b);
void attach(int coefficient, int exponential, poly_pointer *ptr);
int compare(int x, int y);


main() {       
    a = (poly_pointer)malloc(sizeof(poly_node));
    attach(3, 14, &a);
    attach(2, 8, &a);
    attach(1, 0, &a);
    printf("%d", &a);
}

poly_pointer padd(poly_pointer a, poly_pointer b) {
    poly_pointer front, rear, temp;
    int sum;
    rear = (poly_pointer)malloc(sizeof(poly_node));
    if(IS_FULL(rear)) {
        fprintf(stderr, "The memory is full\n");
        exit(1);
    }
    front = rear;
    while(a && b)
        switch(compare(a -> expon, b -> expon))    {
            case -1:
                attach(b -> coef, b -> expon, &rear);
                b = b -> link;
                break;
            case 0:
                sum = a -> coef + b -> coef;
                if(sum) attach(sum, a -> expon, &rear);
                a = a -> link; b = b -> link;
                break;
            case 1:
                attach(a -> coef, a -> expon, &rear);
                a = a -> link;
        }
    /* 리스트 a와 리스트 b의 나머지를 복사하기 위한 부분 */
    for(;a;a->link) attach(a -> coef, a -> expon, &rear);
    for(;b;b->link) attach(b -> coef, b -> expon, &rear);
    rear -> link = NULL;
    /* 필요없는 초기 노드를 삭제 */
    temp = front; front = front -> link; free(temp);
    return front;
}

void attach(int coefficient, int exponent, poly_pointer *ptr)    {
    poly_pointer temp;
    temp = (poly_pointer)malloc(sizeof(poly_node));
    if(IS_FULL(temp)) {
        fprintf(stderr, "The memory is full\n");
        exit(1);
    }
    temp -> coef = coefficient;
    temp -> expon = exponent;
    (*ptr) -> link = temp;
    *ptr = temp;
}

int compare(int x, int y) {
    if(x < y)
        return -1;
    else if(x == y)
        return 0;
    else
        return 1;
}




--------------------Configuration: poly_pointer_padd - Win32 Debug--------------------
Compiling...
poly_pointer_padd.c
C:\......\poly_pointer_padd.c(19) : error C2065: 'poly_node' : undeclared identifier
Error executing cl.exe.

poly_pointer_padd.obj - 1 error(s), 0 warning(s)

+ -

관련 글 리스트
38061 헤더파일을 include 해주지 않아서 그런 걸까요? 서찬 877 2004/11/16
38074     Re:헤더파일을 include 해주지 않아서 그런 걸까요? 가제트 895 2004/11/17
38067     Re:헤더파일을 include 해주지 않아서 그런 걸까요? 강재호.만해 973 2004/11/17
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.