This topic created in 3593 days ago, the information mentioned may be changed or developed.
#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 replies 2016-06-29 10:16:59 +08:00  | | 1 wsy2220 Jun 28, 2016 #include 就是单纯的文本替换 |
 | | 4 sean10 Jun 28, 2016 via iPhone 建议你去看下 c 的工程是怎么建立的,看下头文件是怎么回事还有多文件编译 |
 | | 5 sean10 Jun 28, 2016 via iPhone 你发的帖子都是能在搜索引擎中搜到的问题……不知道你用的是什么参考书,不过我想应该都有提到编译流程,数据类型转换之类的名词,善用这些名词去搜吧 |
 | | 6 ecnelises Jun 29, 2016 via iPhone 你的 test.h 在哪 |
 | | 7 jasonlz Jun 29, 2016 函数库也不是.c 文件啊,是.h 和编译好的 lib 文件 |