FILE *in,*out;
in = fopen("in.txt","r");
out = fopen("out.txt","w");
我将以上放在main() 外面
结果提示:
error C2040: 'in' : 'int ' differs in levels of indirection from 'struct _iobuf *'
error C2099: initializer is not a constant
error C2040: 'out' : 'int ' differs in levels of indirection from 'struct _iobuf *'
error C2099: initializer is not a constant
放在里面也试过了,还是错
以下是完整代码:
#define LEN sizeof(struct tree)
#include
struct tree
{
char name[30];
char attr[100];
struct tree *left,*right,*lup,*rup;
};
FILE *in,*out;
void write(struct tree *p,int n)
{
int i;
for (i=0; iname,p->attr);
if (p->right!=0) wirte(p->right,n+1);
else write(p->left,n);
}
main()
{
char s;
int k,j;
struct tree *q,*p,*p1,*root;
in = fopen("in.txt","r");
out = fopen("out.txt","w");
root = p = (struct tree*) malloc(LEN);
p->left=0; p->right=0; p->lup=0;p->rup=0;
s = fgetc(in);
while (s!=EOF)
{中间这段可以忽略 跟输出完全无关,字数有限就不发了}
write (root,0);
fclose(in);
fclose(out);
}
这是错误提示:lab2_2.obj : error LNK2001: unresolved external symbol _wirte
Debug/lab2_2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
用的VC6.0 编译,TURBO C也错
|