일단 컴파일러가 C++이 아니라면 모르겠지만 new라는 키워드를 변수로 이용한것이 문제입니다.
new를 모두 n으로 변경 하시고요
cellCDT 구조체 선언에 마지막 } 다음에 ;요게 빠졌습니다.
그리고 main이 없으니 링크에러가 나겠죠.
메인 함수가 없는 부분일거라 생각 되니까.
일단 new를 변수처럼 이용한게 문제 입니다.
C만 지원하는 컴파일러에서는 에러가 없을지 모르겠네요..
남지민 님이 쓰신 글 :
: //cell.h
: typedef struct cellCDT *cell;
: cell new_cell(void); /* create new cell*/
: void create_child( cell x, int y); /*creates a child in given cells children area with value*/
: void free_cell( cell x ); /* frees cell */
: float get_val(cell x); /*return strng held in cell*/
: void c_val(cell x, float y); /* change value of cell*/
: cell lreturn(cell x);
: cell rreturn(cell x);
:
: ---------------------------------------------------------------------------------------
:
:
: #include <stdio.h>
: #include <stdlib.h>
: #include <string.h>
: #include "cell.h"
:
: struct cellCDT{
: struct cellCDT* left; //struct of each cell uniform across all
: struct cellCDT* right; //due to laziness
: float value;
: }
:
:
:
: /*//////////////////////////////////////////////////////////
: // creates and initializes new cell with no input
: //
: //////////////////////////////////////////////////////////*/
: void new_cell()
: {
: cell new = (cell)malloc( sizeof(*new) );
: new->left=NULL;
: new->right=NULL;
: new->value=0;
: return new;
: }
:
:
: /*********************************************************
: ** create child under a cell and add pointer to that cell's newly expanded
: **array
: ******************************************************************************/
: void create_child( cell x, int y)
: {
: cell child_cell = new_cell();
: if(y==0)
: {
: x->left = child_cell;
: //innate bias to do nothing
: }
: else x->right = child_cell;
: }
:
:
: /***************frees all parts of cell and then frees self*******************/
: void free_cell( cell x )
: {
: if(x->left != NULL) free_cell(x->left);
: if(x->right != NULL) free_cell(x->right);
: free(x);
: }
:
:
: /***************return strng held in cell*************************************/
: float get_val(cell x)
: {
: return x->value;
: }
:
: /**************change value of cell******************************************/
: void c_val(cell x, float y)
: {
: x->value = x->value + y;
: }
:
: cell lreturn(cell x)
: {
: return x->left;
: }
:
: cell rreturn(cell x)
: {
: return x->right;
: }
|