Skip to content
Devtoolry

C Compiler

Compile and run C code online with Clang 21 and stdin input. Your program is compiled to WebAssembly and runs in your browser, so the code stays on your device.

About the C Compiler

The online C Compiler builds your program with Clang 21 (C17) and runs it straight away, so you can test a function, check pointer arithmetic or practise for an exam without installing GCC or an IDE. The compiler itself runs in your browser as WebAssembly: your code is never uploaded.

Your code runs in an isolated Web Worker in your browser, so it never leaves your device.

How to use the C Compiler

  1. Write or paste a C program with a main() function.
  2. Put any input your program reads (scanf, fgets) in the stdin box.
  3. Click Run. The first run downloads the compiler (about 23 MB); later runs reuse it.
  4. Read compiler warnings and errors, then the program output and exit code.

Example

Read numbers until the input ends

Input

#include <stdio.h>

int main(void) {
    int n, sum = 0;
    while (scanf("%d", &n) == 1) sum += n;
    printf("Sum: %d\n", sum);
    return 0;
}

Result

Sum: 108

With "4 8 15" and "16 23 42" on two stdin lines. scanf returns EOF when the stdin box is used up, which ends the loop.

Common mistakes

  • Waiting for keyboard input. There is no interactive terminal. Type everything the program reads into the stdin box before you click Run; once it is used up, scanf returns EOF and fgets returns NULL.
  • Null pointers do not always crash. In WebAssembly, address 0 is ordinary memory, so reading through a NULL pointer returns garbage instead of a segmentation fault. Out-of-bounds access past the end of memory and stack overflows do stop the program with a runtime error.
  • Files, sockets and threads. fopen, socket calls and pthread_create fail in the sandbox. Read data from stdin and keep the program single-threaded.

Works well with the C Compiler

Frequently asked questions

Which C standard and compiler are used?

Clang 21 with -std=c17 -O2 -Wall, linking the WASI C library (a musl-based libc) and the maths library. Code that compiles with GCC in C17 mode almost always compiles here too.

Why is the first run slower?

The Clang toolchain is downloaded once (about 23 MB compressed) and then cached by your browser. Later runs only compile and execute your code.

Is this GCC?

No, it is Clang, which accepts the same C syntax and almost all GCC extensions. Code written for gcc -std=c17 normally compiles unchanged; GCC-only flags are not needed.

Is my code sent to a server?

No. Both the compiler and your program run in your browser as WebAssembly, so the code and its input stay on your device.

Does it work offline?

After the first run the compiler is in your browser cache, so later runs work even on a slow connection. The page itself still needs to load.