Online C Compiler: write, compile and run C in your browser

C (Clang 22)

main.c

Output

Output appears here when you press Run.

Input

What is C?

C is one of the oldest programming languages still in everyday use, and one of the most influential. Operating systems, databases, embedded devices and the interpreters of languages like Python are written in it. Learning C teaches how a computer actually works — memory, pointers, and what your code turns into — which is why it remains a core subject in computer science courses.

Why use an online C compiler?

  • Nothing to install. No gcc, no MinGW, no Xcode tools, no build setup. Open the page and start writing, on any computer.
  • Real compiler errors. Mistakes come back as the same line-and-column messages, with a caret under the problem, that a compiler on your own machine gives.
  • Practise as you learn. Run the examples from a course or textbook as you read them, change them, and see what breaks.

Example

main.c
#include <stdio.h>

int main(void) {
    const char *names[] = {"Meera", "Asha", "Rohan"};
    int scores[] = {95, 88, 72};

    for (int i = 0; i < 3; i++) {
        char grade = scores[i] >= 85 ? 'A' : 'B';
        printf("%-6s %d  %c\n", names[i], scores[i], grade);
    }
    return 0;
}
Output
Meera  95  A
Asha   88  A
Rohan  72  B

About Gradient Learning's C Compiler

It is the real Clang 22 compiler, built to run inside your browser, so your code never leaves your computer. Programs are compiled with warnings on and optimisation off, the way a C course compiles them, and extra checks make a null pointer or an array index out of range stop the program with an error rather than silently corrupt memory.

What can you do with it?

  • Write, compile and run C programs, free, with no sign-up
  • Use the standard library: stdio.h, stdlib.h, string.h, math.h, ctype.h, time.h and the rest
  • Read input with scanf, fgets and getchar
  • See compiler errors and warnings with line and column numbers
  • Open a .c file, and download your code as main.c
  • Stop a program that runs too long, with one click

How to use the tool

  1. Write or paste your code into the main.c panel on the left.
  2. If your program reads input, type it in the Input box on the right, one value per line.
  3. Press Run, or Ctrl+Enter (⌘+Enter on a Mac). The program is compiled and run, and its output and any errors appear in the Output panel.

The first run takes a little while as the compiler downloads. After that it is cached, and programs compile in a fraction of a second.

Frequently asked questions

Is my code uploaded anywhere?

No. The compiler itself runs inside your browser, and so does your program. Your code is never sent to a server, stored or logged. The only download is the compiler, the first time you press Run.

Which compiler and C standard does it use?

Clang 22, the same compiler that ships with Xcode and much of Linux, in C17 mode with GNU extensions (-std=gnu17). That is what gcc used by default for years, so code from nearly any C tutorial or textbook compiles as written. Warnings are on (-Wall) and optimisation is off (-O0), the way a C course compiles its examples.

Why is the first run slow?

The first time you press Run, your browser downloads the compiler, about 23 MB. That takes a few seconds on a good connection. It is cached after that, so later visits start straight away and programs compile in a fraction of a second.

How do I give my program input?

Type it in the Input box before you press Run, one value per line. scanf, fgets, getchar and the rest read from it in order, and each line your program reads is shown in green in the output, so the transcript reads like a terminal session.

What happens when my program crashes?

It stops with an error that says what went wrong and which of your functions it was in: a division by zero, a stack overflow from runaway recursion, or a crash from a null pointer or an array index out of range, the kind of bug your own computer reports as a Segmentation fault. The compiler adds checks for those last two, because inside a browser they would otherwise corrupt memory silently.

What is not supported?

Anything that needs an operating system beyond the terminal: files outside the program's own memory, network sockets, threads, fork and system(). Libraries that are not part of the C standard library, such as conio.h or graphics.h, are not available either. Very deep recursion, tens of thousands of calls, can hit the browser's stack limit sooner than a desktop would.

My program never finishes. What do I do?

Press Stop. It ends the program immediately, including an endless loop, and the compiler stays loaded, so the next Run is instant.

Does it support C++?

Not on this page, which compiles C only: C++ code will fail with errors about unknown keywords such as class or namespace. Use the C++ Compiler, in the same set of tools, for C++.