Lesson 2: Setting Up the Environment
To write and run C code, you need two main tools: a text editor (or IDE) and a compiler.
The C Compiler
The compiler translates human-readable C code into machine-readable executable code. The most common compiler suite is GCC (GNU Compiler Collection).
Installation Steps (General)
- Linux (Debian/Ubuntu): Use
sudo apt install build-essential(which includes GCC). - macOS: Install Xcode Command Line Tools (
xcode-select --install). - Windows: Use MinGW-w64 (Minimalist GNU for Windows) or install a distribution like MSYS2, which provides GCC.
Integrated Development Environment (IDE) or Text Editor
For beginners, an IDE can simplify the compilation process, but a powerful text editor paired with a terminal is often preferred by professionals.
| Tool Type | Examples | Notes |
|---|---|---|
| IDE | Code::Blocks, Visual Studio, Eclipse | Good for beginners, all-in-one package. |
| Editor | VS Code, Sublime Text, Vim | Requires manual compilation steps, highly customizable. |
Verification
After installation, open your terminal/command prompt and type:
bash gcc --version
If the installation was successful, you will see the version number of your compiler.