我有两个文件:getParams.c
和tree.c
.
我想要做的是tnode
从tree.c
我的getParams.c
.
我不记得如何正确包含来自其他源文件的代码。
获取参数.c
#include <stdlib.h>
int main(int argc, char *argv[]) {
tnode *doublyLinked;
addtree(doublyLinked, argv[1]);
return 0;
}
树.c
/*
* Tree routines from Kernighan and Ritchie
* Chapter 6.
*/
#include <stdio.h>
#include <string.h>
#define EOS '\0'
#define LETTER 'a'
#define DIGIT '0'
#define MAXWORD 20
struct tnode{ /* the basic node */
char *word; /* points to the text */
int count; /* number of occurrences */
struct tnode *left; /* left child */
struct tnode *right; /* right child */
};
main(){ /* word frequency count */
struct tnode *root, *addtree();
char word[MAXWORD];
int t;
root = NULL;
while((t=getword(word, MAXWORD)) != EOF)
if (t == LETTER)
root = addtree(root,word);
treeprint(root);
}
... more code
我得到的错误
gcc getParams.c tree.c -o getParams
getParams.c: In function ‘main’:
getParams.c:5:2: error: unknown type name ‘tnode’
我可以得到你的帮助吗?