The Preprocessor is the [[The C Programming Language#Overview of Compiliation|the first stage of compilation]].
All *Preprocessor Statements* start with a `#`.
```c
#include <stdio.h>
int main() {
printf("Hello World!\n");
return 0;
}
```
What the Preprocessor does can be boiled down to mainly copy, cut, and paste.
## Types of Preprocessor Statements
### `#include`
What the `#include` statement does, is find the file specified, and simply replace the statement with the contents of the file.
> [!example]
> ```c
/* functions.c */
> int get_funny_number() {
> return 69;
> }
>
> /* main.c *
> #include "functions.c"
> #include <stdio.h>
>
>int main() {
> printf("%d\n", get_funny_number());
>}
The common example of this is part of the classic "hello world"
```c
#include <stdio.h>
int main() {
printf("goofy ahh preproc statements heart emoji\n"));
}
```
The `#include <stdio.h>` will find a file called *stdio.h* and simply copy the contents into your file. *stdio.h* is a [[Header Files|Header File]], so all this preprocessor directive does is let the compiler know you are using functions / definitions relating to do with the IO functionality [[Standard Library]], *eg.* printing to the console.
> [!example]
> title: cringe with **\#include**
> If you create a header file with a single semi colon, because all **\#include** statements simply just copy and paste.
>
> Just putting a semicolon in a file allows you to replace your semi colons with `#include "semicolon.h"`, and your program will compile successfully.
>
>
> ```c
> /* semicolon.h */
> ;
>
> /* main.c */
> #include <stdio.h>
>
> int main() {
> printf("Hello world\n") #include "semicolon.h"
> }
> ```
### `#pragma once`
This preprocessor directive is used in [[Header Files]] as a way of preventing your code from being duplicated multiple times when you use `#include`, what actual goes on with it is over my head - so just know that it is used at the top of [[Header Files]].
> [!example]
> ```c
> /*test.h*/
> #pragma once
>
> void sample_function();
> ```