Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
C is a compact, procedural language that Dennis Ritchie created at Bell Labs in the early 1970s to rewrite the Unix operating system, and it remains one of the most influential languages ever designed. It sits very close to the hardware: you manage memory yourself, work directly with pointers, and get almost no runtime between your code and the machine. The language has been standardized repeatedly — from ANSI C89 through C99, C11, C17, and the recent C23 — while keeping remarkable backward compatibility. On XCODX your source is compiled with GCC (the exact version is shown in the badge) and run in a cloud sandbox, so you can test standard C without installing a toolchain. Because it is small and predictable, C is still the default language for operating-system kernels, device drivers, and embedded firmware in 2026.
#include <stdio.h>
/* Sum the first n whole numbers */
long sum_to(int n) {
long total = 0;
for (int i = 1; i <= n; i++) {
total += i;
}
return total;
}
int main(void) {
int n = 10;
printf("Hello from C!\n");
printf("Sum of 1..%d = %ld\n", n, sum_to(n));
return 0;
}
C's strengths are minimalism, speed, and total control: there is no garbage collector, the compiled binary is tiny, and its predictable memory model maps almost one-to-one onto the CPU. Choose C when you are writing an OS kernel, a device driver, embedded or real-time firmware, or a small high-performance library that other languages will call through a stable ABI. It is also the classic language for learning how memory, pointers, and the stack really work. The honest trade-off is that C gives you no safety net — no bounds checking, no built-in strings or containers, and manual memory management — so for quick scripts or large memory-safety-critical apps a higher-level language or Rust is usually a better fit.
Use scanf with the address-of operator (for example scanf("%d", &n);) or fgets for whole lines, exactly as you would locally. XCODX gives you a live terminal, so the program pauses when it reaches scanf and reads whatever you type; alternatively, paste all your input into the Stdin Box before running. Send EOF with Ctrl+D to close the stream. Remember that scanf leaves the trailing newline in the buffer, which is the usual reason a later %c or fgets seems to be skipped.
No. The sandbox has no package manager and no way to link third-party libraries — there is no apt, no vcpkg, no conan, and no network access to fetch anything. You can #include the C standard library and standard system headers (stdio.h, stdlib.h, string.h, math.h, and so on), which cover a lot, but anything outside the standard library is unavailable here.
Your code is compiled with GCC, and the exact build is shown in the version badge next to the run button. The C standard features you can use track that GCC version's default, and you cannot pass your own flags such as -std=c23, -O2, or -fsanitize=address. For portable examples, stick to widely supported standard C rather than the very newest additions.
In C, local variables are not automatically initialized, so reading one before you assign it is undefined behavior and often prints leftover memory. The same applies to using an uninitialized pointer or indexing past the end of an array. Always initialize your variables (int total = 0;) and stay inside array bounds; because the sandbox does not surface compiler warnings or run a sanitizer, these bugs tend to fail silently.
The runner is built around a single source file, so the reliable approach is to keep everything — your functions, structs, and main — in one file. Splitting into separate translation units or custom headers is fragile on this backend, and there is no persistent filesystem between runs. For tutorials and testing, one self-contained file is the way to go.
C is the smaller language: fewer concepts, no classes or templates, and it forces you to understand memory directly, which many people find a cleaner foundation. C++ is far larger but adds objects, generics, and a rich standard library for building bigger applications. If your goal is embedded systems or understanding fundamentals, start with C; if you want general-purpose application or game development, C++ may be the better first step.
main.ctext/x-csrcscanf() / fgets()#include <stdio.h>
int main() {
printf("Hello from C!\n");
printf("Welcome to XCODX Online Compiler!\n");
return 0;
}