About the C compiler
How to use the C compiler
Type or paste your program in the editor, or pick a starter program from Templates: scanf and printf, arrays, recursion, sorting, a linked list and files. Press Run (or Ctrl+Enter). The output appears on the right, or in the Output tab on a phone, with how long the program took and the exit code that main returned.
Your code, input and tests are saved on this device as you type. Share makes a link with the code and input inside it; nothing is uploaded.
How input works
Everything in the Input tab is given to the program as its standard input, as if you had typed it in a terminal before it started. scanf, getchar and fgets(..., stdin) read from it in order, across lines. Put one value for each %d your scanf reads; values may be separated by spaces or new lines. If a read finds no input left, scanf returns EOF, and the compiler tells you the program wanted more.
What runs your code
C runs in your browser on StepVioz's own C interpreter, not on a server. It follows the C standard closely and checks every step: an index outside an array, an uninitialized variable, integer overflow, a NULL or dangling pointer, use after free and printf formats that do not match their arguments all stop the program with the line and a plain explanation, where a real compiled program would crash later or print garbage. Files written with fopen live in memory and disappear when the run ends.
Each run may take 5 seconds; then it is stopped. Output is kept up to 10,000 lines or 1 MB, and the rest is cut with a notice. Programs cannot reach the network, and no packages or libraries can be installed: what a language brings with it is what you can use. An interpreter is slower than compiled code: a few million loop steps per second, which is plenty for course work but not for contest programs that run a hundred million steps.
See it step by step
Visualize this run opens the same code and input in the C code visualizer: it runs one line at a time and draws the call stack, every variable, arrays and the heap, with pointers as arrows. It is the clearest way to see why a pointer or a loop does what it does. The visualizer follows the first 1,000 steps, so keep the input small.
Questions
- Is this a real C compiler like gcc?
- No. It is StepVioz's C interpreter, which runs in your browser. It accepts standard C and gives the same output as gcc for correct programs, but it also stops and explains undefined behaviour that gcc would let through.
- Why does my program say it wants more input?
- scanf read past the end of the Input tab. Add one value for each value the program reads, then run again.
- Can I use files?
- Yes: fopen, fprintf, fscanf, fgets, fputc and the rest work on files kept in memory. A file exists only during the run that wrote it.
- Which headers are available?
- stdio.h, stdlib.h, string.h, math.h, ctype.h, limits.h, stdbool.h, stdint.h, time.h and assert.h, with the functions courses use.
- Does my code leave my computer?
- No. It runs in your browser in a sandbox with no network access, and it is saved only on this device.
See also
- The C code visualizer: run code one step at a time and see its memory.
- Structured Programming in C: the course, with lessons and examples you can open here.
- Data Structures: the course, with lessons and examples you can open here.
- Algorithms: the course, with lessons and examples you can open here.
- Foundations: how computers work: the course, with lessons and examples you can open here.
- Developer Tools: the course, with lessons and examples you can open here.
- Operating Systems: the course, with lessons and examples you can open here.
- Practice problems, checked against hidden tests.
- Online Python compiler
- Online C++ compiler
- Online Java compiler
- Online SQL compiler
- Online JavaScript compiler
- Online 8086 Assembly compiler