← Back to C Course | Chapter 1: Introduction & Basics | Lesson 3 of 21

C Environment Setup

Compiler Overview

A compiler translates your human-readable C source code into machine instructions the processor can actually execute. GCC (GNU Compiler Collection) is the most widely used free compiler and is available on virtually every platform, including inside cookiescursor.com's own Try It tool.

Example: Compiler Overview

c
#include <stdio.h>
int main() {
	printf("Compiled with GCC into a native executable.");
	return 0;
}

Text Editors

Any plain text editor can write C, but ones built for coding -- VS Code, Vim, or an IDE -- add syntax highlighting and error detection that catch typos before you even compile, saving you from cryptic compiler errors later.

Example: Text Editors

c
#include <stdio.h>
int main() {
	printf("A good editor highlights syntax errors before you compile.");
	return 0;
}

Writing Your Code

Source files must use the .c extension so the compiler and your editor both recognize them as C code and apply the correct syntax rules; using the wrong extension is a common reason a compiler refuses to build a file at all.

Example: Writing Your Code

c
// Save this file as: hello.c
#include <stdio.h>
int main() {
	printf("Saved with a .c extension so the compiler recognizes it.");
	return 0;
}

Compiling Your Code

Running gcc filename.c -o output reads your source file, checks it for syntax errors, and if it compiles cleanly, produces a binary executable -- any error messages printed here point to the exact line where the compiler got confused.

Example: Compiling Your Code

c
// Compile with: gcc hello.c -o hello
#include <stdio.h>
int main() {
	printf("Run 'gcc hello.c -o hello' to compile this file.");
	return 0;
}

Running the Output

The compiled binary (typically named a.out on Linux/Mac or filename.exe on Windows) is a standalone program -- running it executes your code directly on the CPU, with no compiler or interpreter needed at that point.

Example: Running the Output

c
// After compiling: ./hello  (Linux/Mac) or hello.exe (Windows)
#include <stdio.h>
int main() {
	printf("This runs as a standalone compiled binary.");
	return 0;
}

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.