C语言声明和实现分开例子
通常将c函数的声明放在头文件,实现放在另一个文件,最后函数被其他文件调用。
一、声明
1 //last.h
2
3 #include <stdio.h>
4
5 void test1();
二、实现
1 //last.c
2
3 #include "last.h"
4
5 void test1(){
6 printf("hello world");
7 }
三、调用
//name.c
#include "last.h"
int main(){
test1();
}
四、编译运行
#gcc last.c -c
#gcc last.o name.c -o end
#./end
浙公网安备 33010602011771号