自定义文件
hello.h
#ifndef HELLO_H
#define HELLO_H
//function
void hello();
#endif
hello.c
#include "hello.h"
//function
void hello()
{
printf("hello world!");
}
main.c
#include <stdio.h>
#include "hello.h"
void main()
{
hello();
}
编译运行
方法1
gcc hello.c -o hello.o
gcc main.c -o main hello.o
方法2
gcc mian.c -o main hello.c
方法3
自定义makefile
helloprogram: hello.h hello.c main.c
gcc -o helloprogram main.c hello.c
clean:
rm helloprogram
然后
make