john_he
发表于 2007-8-17 21:52:08
可以的
august
发表于 2007-8-17 23:23:26
引用第10楼john_he于2007-08-17 21:52发表的:
可以的
那教教我怎么做嘛
john_he
发表于 2007-8-17 23:30:45
你那个方法(就是写个xxx.h放到include目录里在xxx.c里#include)是可行的,注意下那个include目录在编译器的搜索范围内就可以了。
我怀疑你那错误是别的原因导致的。
august
发表于 2007-8-17 23:37:50
刚刚我又在机子上运行原来的程序,报错了, " unabletoopenincluefile'TEXT.H'"怎么回事呢?
john_he
发表于 2007-8-17 23:57:57
你那.c和.h文件放哪里啊?给个完整路径。
还有有没有打错字……
august
发表于 2007-8-18 00:06:37
#define LAG >
#define SMA <
#define EQ ==
#include "test.h"
#include "stdio.h"
void main()
{ int i=10;
int j=20;
if(i LAG j)
printf("\\40: %d larger than %d \\n",i,j);
else if(i EQ j)
printf("\\40: %d equal to %d \\n",i,j);
else if(i SMA j)
printf("\\40:%d smaller than %d \\n",i,j);
else
printf("\\40: No such value.\\n");
}
我现在这样写也报错,
另外的方法我把 text.h 写好后直接另存为.h文件,直接放在INCLUDE文件夹里,还有我是用EditPlus编写好代码再保存的
.c 的文件就在TC的文件夹里,INCLUDE的文件夹在TC的文件夹里
john_he
发表于 2007-8-18 00:14:43
放到和.c同目录试下
august
发表于 2007-8-18 00:18:52
还是不行,而且现在发现这样写在一起也报错
#define SMA <
#define EQ ==
#include "test.h"
#include "stdio.h"
void main()
{ int i=10;
int j=20;
if(i LAG j)
printf("\\40: %d larger than %d \\n",i,j);
else if(i EQ j)
printf("\\40: %d equal to %d \\n",i,j);
else if(i SMA j)
printf("\\40:%d smaller than %d \\n",i,j);
else
printf("\\40: No such value.\\n");
}
john_he
发表于 2007-8-18 00:44:56
test.h
text.h
是不是这个问题
august
发表于 2007-8-18 09:24:36
不是哦,我现在没有另存一个 test.h 文件,是直接把这些所有的语句都放在一起然后编译报错