Loading
...
c-runner logo

c-runner

The fastest way to compile and run C/C++ code โ€” single files or full projects, with live watch mode.

v2.2.0ยท
Visitors:
bash
$ c-runner main.c -i input.txt -o output.txt --watch
๐Ÿ”จ Compiling main.c...
โœ… Compiled in 38ms
โ–ถ๏ธ Running...
---
$ โ–ˆ
scroll
Features

Everything you need

No config required to get started.

01

C & C++ Support

Compile .c files with gcc, .cpp files with g++. Automatic compiler detection based on file extensions.

02

Watch Mode

Auto-recompile on file changes using inotifywait, fswatch, entr, or built-in polling as fallback.

03

File I/O Mode

Pipe input.txt into stdin and capture program output to output.txt โ€” perfect for testing scanf-based programs.

04

Auto Starter

Missing or empty .c or .cpp file? c-runner creates it with Hello World starter code and runs it immediately.

05

Configurable

Use config.yml or environment variables to customize source, build directories, and file I/O per project.

06

Clean Execution

Single files compile to a temp binary, run, then clean up automatically โ€” zero leftover files.

Installation

Installation

Get up and running in under a minute.

1. Install dependencies
sudo apt update                                  # refresh package list
sudo apt install build-essential inotify-tools   # gcc, g++ + file watcher for watch mode
2. Download & install c-runner
wget https://c-runner.vercel.app/c-runner        # download the binary
chmod +x c-runner                                # make it executable
sudo mv c-runner /usr/local/bin/                 # install globally
c-runner --version                               # verify installation
Tutorial

Tutorial

See c-runner in action.

Usage

Usage

All available commands organized by language.

General Commands

Version
c-runner --version

Display version and author information.

Help
c-runner --help

Show all available commands and options.

Initialize config
c-runner --init

Create a config.yml with default src_dir, build_dir, and file_mode settings.

Run project (all files)
c-runner run

Compile all .c and .cpp files. Uses g++ if any .cpp files exist, otherwise gcc.

Watch project
c-runner run --watch

Auto-recompile the entire project on any .c or .cpp file change.

Run C file
c-runner main.c

Compile with gcc and run. Auto-creates file with C starter code if missing.

Watch C file
c-runner main.c --watch

Auto-recompile with gcc on every save. Creates C starter code if missing.

C with stdin
c-runner main.c -i input.txt

Pipe input.txt into stdin for scanf() โ€” each line feeds the next scanf call.

C with output capture
c-runner main.c -o output.txt

Write printf() output to output.txt. Overwrites on every run.

C: full I/O + watch
c-runner main.c -i input.txt -o output.txt --watch

Watch mode with file I/O for C โ€” reruns on main.c or input.txt changes.

Configuration

Configuration

Customize per project with a simple YAML file.

config.yml
# GCC Build Configuration
src_dir: src
build_dir: build

# File I/O mode (optional)
# file_mode:
#   input: input.txt        # pipe this file into stdin
#   output: output.txt      # write program output to this file
#   view_terminal: true     # also print output to terminal (default: false)
input.txt
# comment lines are ignored โ€” use them to document your inputs
10 20       # a and b

# next scanf value
300

How It Works

  • โ†’Single file โ€” compiles .c with gcc, .cpp with g++. Creates starter code if file is missing or empty.
  • โ†’Project mode โ€” compiles all .c and .cpp files. Uses g++ if any .cpp files exist, otherwise gcc.
  • โ†’File I/O โ€” CLI flags -i / -o override config.yml values.
  • โ†’input.txt comments โ€” lines starting with # are stripped before being piped to stdin.

Config Keys

  • src_dirSource directory (default: .)
  • build_dirBuild directory (default: build)
  • inputStdin source file (default: โ€”)
  • outputStdout target file (default: โ€”)
  • view_terminalAlso print to terminal (default: false)
Uninstall

Uninstall

Remove c-runner
sudo rm /usr/local/bin/c-runner