这是一个创建于 3032 天前的主题,其中的信息可能已经有所发展或是发生改变。
#include <stdio.h>
#define TARGET_AGE 88
int year1, year2;
int calcYear (int year1);
int main (void)
{
printf("What year was the subject born?");
printf("Enter as a 4-digit year (YYYY): ");
scanf(" %d", &year1);
year2= calcYear(year1);
printf("Someone born in %d will be %d in %d.",
year1, TARGET_AGE, year2);
system("pause");
return 0;
}
int calcYear(int year1)
{
return (year1 + TARGET_AGE);
}
把以上内容分为下面的两部分(以上的是书里的,下列的两部分由本人自己编辑)
/*test.c*/
#define TARGET_AGE 88
int year1;
int calcYear(int year1);
int main (void)
{
int calcYear(int year1);
{
return (year1 + TARGET_AGE);
}
}
和
/*include.c*/
#include <stdio.h>
#include <test.h>
#define TARGET_AGE 88
int year1, year2;
int calcYear(int year1);
int main (void)
{
printf ("What year was the subject born? ");
printf ("Enter as a 4-digit year (YYYY):");
scanf(" %d ", &year1);
year2 = calcYear(year1);
printf("Someone born in %d will be %d in %d.",
year1, TARGET_AGE, year2);
return 0;
}
如果我把 test.c 加入到 C 编译器的库函数里后(这个不知道行不,或者自己创建函数库?),再编辑 include.c 并编译,这样可以成功执行吗?
7 条回复 • 2016-06-29 10:16:59 +08:00
|
|
1
wsy2220 2016-06-28 20:14:30 +08:00
#include 就是单纯的文本替换
|
|
|
3
creater17 2016-06-28 22:34:07 +08:00
我这描述可能有问题,求指教
|
|
|
4
sean10 2016-06-28 23:36:35 +08:00 via iPhone
建议你去看下 c 的工程是怎么建立的,看下头文件是怎么回事还有多文件编译
|
|
|
5
sean10 2016-06-28 23:39:35 +08:00 via iPhone
你发的帖子都是能在搜索引擎中搜到的问题……不知道你用的是什么参考书,不过我想应该都有提到编译流程,数据类型转换之类的名词,善用这些名词去搜吧
|
|
|
6
ecnelises 2016-06-29 08:12:31 +08:00 via iPhone
你的 test.h 在哪
|
|
|
7
jasonlz 2016-06-29 10:16:59 +08:00
函数库也不是.c 文件啊,是.h 和编译好的 lib 文件
|