> ## Documentation Index
> Fetch the complete documentation index at: https://hypotenuse.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Started with C△: Your First Program in 5 Minutes

> Write a C△ source file, compile it to a native binary with the Hypotenuse Compiler, and run it — all in under five minutes with zero prior C△ experience.

In this guide, you will write a C△ program, compile it into a native binary using the `hypotenuse` command, and run it on your machine. By the end, you will have a working development loop and a clear picture of how a C△ source file is structured. If you have not installed the compiler yet, start with the [Installation Guide](/installation) first.

## Write Your First Program

Create a new file called `hello.ctri` and add the following code.

```c hello.ctri theme={null}
using <plstd>;

int main() {
    printd@lib("Hello, C△!");
    return 0;
}
```

Save the file. That is all the source code you need for a complete, runnable C△ program.

## Compile and Run

<Steps>
  <Step title="Save the file">
    Make sure the file is saved as `hello.ctri` in your current working directory. C△ source files always use the `.ctri` extension.
  </Step>

  <Step title="Compile to an executable">
    Run the following command to compile `hello.ctri` into a native binary.

    ```bash theme={null}
    hypotenuse -c hello.ctri
    ```

    The `-c` flag tells the compiler to invoke GCC after code generation and produce a linked executable. If you omit`-c`, the compiler prints the intermediate C output to stdout instead of producing a binary. The output binary is named `hello` in the current directory.
  </Step>

  <Step title="Run the executable">
    Execute the binary directly.

    ```bash theme={null}
    ./hello
    ```

    You should see the following output in your terminal.

    ```text theme={null}
    Hello, C△!
    ```
  </Step>
</Steps>

## Understanding the Code

Here is what each part of `hello.ctri` does.

* **`using <plstd>;`** — imports the C△ standard library. Angle-bracket imports search the system `PLIBS/` directory that was set up during installation. You can also import individual symbols with `using printd from <plstd>;` if you want to keep the namespace minimal.
* **`int main()`** — the program entry point, identical in signature to standard C. The compiler expects `main` to return an `int`. A return value of `0` signals success to the operating system.
* **`printd@lib("Hello, C△!")`** — a type-aware print function provided by `plstd`. `printd` inspects the type of its argument at compile time and emits the appropriate output routine so that you can pass strings, integers, floats, or other types without format strings.
* Be aware that the compiler will verify whether a library function has been properly globalized or referenced. Check if you used your "@" properly.

## A More Complete Example

The program below introduces three additional features: the `string` type, the `dynam` dynamic array, and the `len` function.

```c example.ctri theme={null}
using <plstd>;

int main() {
    string name = "Hypotenuse";
    dynam int scores = [95, 87, 92, 78];
    int count = len(scores);
    printfs@lib("Language: {name}\n");
    printfs@lib("Scores: {count}\n");
    return 0;
}
```

Compile and run this file the same way as before.

```bash theme={null}
hypotenuse -c example.ctri
./example
```

You should see the following output.

```text theme={null}
Language: Hypotenuse
Scores: 4
```

A few things to note about this example:

* **`string`** is a first-class C△ type. It holds a heap-allocated character sequence and handles duplication and freeing automatically when you reassign or reuse the variable.
* **`dynam int scores`** declares a dynamic array of integers, initialised with an inline list literal. You can grow it at runtime or pass it to any function that accepts an array.
* **`len(scores)`** returns the number of elements in a `dynam` array (or the byte length of a `string`). It is provided by `plstd` and works across collection types.
* **`printfs`** is a formatted print function that uses `{variable}` interpolation syntax instead of C-style `%d`/`%s` format specifiers.

<Tip>
  You can control where the compiler writes the output binary using the `-o` flag: `hypotenuse -c hello.ctri -o build/hello`. Pass extra GCC flags with `-C`, for example `hypotenuse -c -C "-O2" hello.ctri` to enable optimisations.
</Tip>

## Next Steps

<CardGroup cols={2}>
  <Card title="Language Guide" icon="book" href="/language/syntax">
    Explore the full C△ syntax: control flow, functions, structs, lambdas, inline assembly, and the namespace system.
  </Card>

  <Card title="Standard Library" icon="box" href="/stdlib/overview">
    Browse the `plstd` modules — `printd`, `printfs`, string operations, file I/O, and more.
  </Card>

  <Card title="Keywords Reference" icon="tag" href="/reference/keywords">
    A complete list of every C△ keyword and operator with descriptions and usage examples.
  </Card>

  <Card title="CLI Reference" icon="terminal" href="/reference/cli">
    All `hypotenuse` command-line flags, from compiling and debugging to installing `.plib` libraries.
  </Card>
</CardGroup>
