eolas/zk/Entry_point_to_C_programs.md

26 lines
493 B
Markdown
Raw Permalink Normal View History

2025-12-03 17:59:30 +00:00
---
tags:
- C
---
# Entry point to C programs
```c
int main(void)
{
// Instructions
}
```
The braces wrap all code that comprises the program.
The return type is `int`. It receives no arguments so the arguments are `void`.
## Why does it return an `int`?
It returns an `int` because the main function returns a success code: `0` for
success and `1` for error.
As C was divised to create Unix, this fits in with other Unix-like OS behaviour
such as bash scripts returning `0`/`1`.