我在一个函数中引用我在另外函数中写的代码,但是一直报错,下面是其中一个函数的片段,我该怎么才能正确引用
#include <stdio.h>
#include <stdlib.h>
#define maxsize 100
void fun(Node *&t, char *a) {
int i = 0, top = -1, tag;
Node *s[maxsize];
t = NULL;
Node *p;
char ch;
ch = a[i];
while (ch != '\0') {
switch (ch) {
case '(':
top++;
s[top] = p;
tag = 1;
break;
case ')':
top--;
break;
case ',':
tag = 2;
break;
default:
p = (Node *)malloc(sizeof(Node));
p->data = ch ;
p->lchild = p->rchild = NULL;
if (t == NULL) {
t = p;
} else {
switch (tag) {
case 1:
s[top]->lchild = p;
break;
case 2:
s[top]->rchild = p;
break;
}
}
}
i++;
ch = a[i];
}
}
```c
#include<stdio.h>
#include<stdlib.h>
#define maxsize 100
typedef struct Node{
int data;
struct Node *lchild;
struct Node *rchild;
}Node;
int main() {
Node *tree;
char a[] = "(1(2(,),3(4(6,),5)))";
fun(tree, a);
printf("横向输出二叉树:\n");
printftree(tree, 0);
printf("\n");
int h = height(tree);
printf("树的高度为 %d\n", h);
int num = countNodes(tree);
printf("节点数量为 %d\n", num);
printf("递归中序遍历结果:\n");
inordertraverse(tree);
printf("\n");
printf("非递归中序遍历结果:\n");
inordertraverse1(tree);
printf("\n");
printf("层次遍历结果为\n");
leveltraver(tree);
printf("\n");
char x, y;
printf("输入 x 和 y 的值:\n");
scanf(" %c %c", &x, &y);
printf("是兄弟节点就返回 1,否则返回 0: %d\n", findbro(tree, x, y));
if (istree(tree))
printf("是完全二叉树\n");
else
printf("不是完全二叉树\n");
return 0;
}