通常将c函数的声明放在头文件,实现放在另一个文件,最后函数被其他文件调用。
一、声明
//test.h #includeint test_func(char *ptr);
二、实现
//test.c
#include "test.h"
int test_func(char *ptr)
{
printf("%s", ptr);
return 1;
}
三、调用
//run.c
#include "test.h"
int main()
{
char *ptr = "Hello, world!";
test_func(ptr);
return 0;
}
四、编译运行
gcc test.c -c gcc test.o run.c -o run ./run



