# C Playground

Compile and run C in your browser with a WASI Clang toolchain, prepared standard input, console output and coding examples.

## URL

https://ilham.dev/tools/c-playground/

## What It Does

Compile C to WebAssembly in a disposable browser Worker with the browsercc 0.1.1 Clang/LLD toolchain. The compiler and sysroot download from jsDelivr only on Run or when Auto-run is enabled. Exercises cover arithmetic, logic, arrays, functions, structs and pyramid patterns. Code and input are not saved or uploaded by the tool. Compiled code can still make network requests through WASI; only run code you trust.

## Features

- Browser-side Clang compile to WebAssembly
- Prepared standard input
- Run and Stop
- Coding exercises and pyramid patterns

## Input

C source with optional prepared standard input c input.

## Output

Program standard output and standard error plus compiler diagnostics console output.

## Privacy

Processing happens locally in the browser.

No input data is uploaded to ilham.dev.

- Requires login: false
- Requires API key: false
- Stores user data: false


## Examples

- How do I read input?
- Why does the first Run take longer?
- Can I use exceptions, threads, fork or sockets?
- Does selecting an example erase my code?
- Is this a security sandbox?


## Limitations

- The Clang/lld toolchain and sysroot download from jsDelivr on Run; roughly 26 MiB compressed.
- No exceptions, threads or native OS processes; a fresh Worker is created for each run.
- Prepared input is not a live interactive terminal.
- Worker execution is not a security sandbox; code can make network requests.
- Execution is limited to 30 seconds after compilation and 500 output rows.


## Related Tools

- https://ilham.dev/tools/cpp-playground/
- https://ilham.dev/tools/javascript-playground/
- https://ilham.dev/tools/typescript-playground/
- https://ilham.dev/tools/python-playground/
- https://ilham.dev/tools/ruby-playground/


## Questions

### How do I read input?

Fill Standard input before Run, one answer per line, then call fgets or scanf. fgets keeps the trailing newline, so strip it before printing. Missing input returns NULL from fgets. This is prepared input, not a live terminal.

### Why does the first Run take longer?

The Clang compiler, linker and sysroot download from jsDelivr on the first Run — roughly 26 MiB compressed. Runtime loading has a 90-second timeout, followed by a separate 30-second execution limit. Later Runs in the same page reuse the loaded toolchain.

### Can I use exceptions, threads, fork or sockets?

This is a WASI build of Clang, not a desktop toolchain. Exceptions are unavailable in C, and threads, fork, and native OS processes are not supported. The standard C library works for console programs.

### Does selecting an example erase my code?

Yes. C examples are complete programs with their own main, so clicking one replaces the editor and pauses Auto-run. Copy anything you want to keep first.

### Is this a security sandbox?

No. A Worker prevents direct DOM access and can be terminated, but compiled code can make network requests through WASI. The tool itself does not upload or persist code or input. Each Run starts fresh; output is limited to 500 rows.

