{
printf(\ return 0; }
程序运行结果:
六、编程题(共15分)
1、假设在当前目录下有hello.c和hello.h两个文件,其代码如下:请写出相应的Makefile文件,要求生成的目标是hello,并通过伪目标clean能删除hello.c和hello.h。(6分)
/*hello.c*/
#include \int main() {
printf(\}
/*hello.h*/
#include
2、一个程序有main函数,func函数和头文件func.h实现,请写一个makefile来完成该程序的编译。要求将main.c编译生成目标main.o,fun.c编译生成func.o,将main.o和func.o编译生成main,伪目标可删除main.c、func.c和func.h文件。 ⑴//func.c程序清单 #include ―fun.h‖
int max_func(int x,int y) {
if(x>=y) return x; else
return y }
⑵//main.c程序清单 #include ―func1.h‖ int main(void) {
int a,b;
printf(―please enter the number a an b\\n‖); scanf(―%d %d‖,&a,&b) int max=0
max=max_fun(a,b); return 0; }
⑶//func.h程序清单
#include
extern int max_fun(int x,int y)
3、请编写两个应用程序,分别使用exit()和_exit()函数来终止进程,并说明在程序运行结果中如何体现exit()和_exit()函数的不同之处。(9分)