①单个源文件:
1
2
3
4
5
6
7
|
#include <stdio.h>
int
main(
void
)
{
hello(
"Hello World.\n"
);
return
0;
}
|
编译这个hello.c文件
gcc -Wall hello.c -o hello
./hello
②多个源文件
main.c如下:
1
2
3
4
5
6
7
8
|
#include <stdio.h>
#include "hello.h"
int
main(
void
)
{
hello(
"Hello World.\n"
);
return
0;
}
|
hello.c如下:
1
2
3
4
5
6
7
|
#include <stdio.h>
#include "hello.h"
void
hello(
const
char
* string)
{
printf
(string);
}
|
hello.h如下:
1
|
void
hello(
const
char
* string);
|
编译多个文件:
gcc -Wall main.c hello.c -o newhello
./newhello
OK!基本功就是这样,嘿嘿…