Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Setting Up the Development Environment

Lesson 4 of 53 in the free Foundation of C & C++ notes on Siksha Sarovar, written by Rohit Jangra.

Your Tools for Success

To write C code, you need a workflow. While you can use a simple text editor and terminal, most professionals use an Integrated Development Environment (IDE) or a powerful editor like VS Code paired with a compiler.

1. The Compiler (The Translator)

Computers don't understand C code; they understand binary (1s and 0s). The compiler is the bridge that translates your human-readable C code into machine-readable instructions.

  • GCC (GNU Compiler Collection): The industry standard for Linux and the basis for MinGW on Windows. It is open-source, incredibly robust, and widely used.
  • Clang: A modern compiler known for its extremely helpful error messages and fast compilation speeds. It is used by Apple for macOS and iOS development.
  • MSVC: Microsoft's C++ compiler, included with the full Visual Studio IDE.

2. Setting up on Windows (MinGW-w64)

Windows doesn't come with a C compiler by default.

  1. Download the MinGW-w64 installer (look for versions from MSYS2 or standalone builds).
  2. Install the gcc and g++ packages.
  3. CRITICAL STEP: You must add the bin folder of your MinGW installation (e.g., C:\msys64\mingw64\bin) to your system's Path environment variable. This allows you to run gcc from any command prompt.
  4. Verify the installation: Open a Command Prompt or PowerShell and type gcc --version. If it shows a version number, you're ready!

3. Setting up on Linux

Linux is the native home of C. Most distributions have it pre-installed or very easy to get.

  • Ubuntu/Debian: Run sudo apt update && sudo apt install build-essential. This command installs GCC, G++, and other vital tools like make and gdb.
  • Fedora/RHEL: Run sudo dnf groupinstall "Development Tools".

4. Setting up on macOS

  • The easiest way is to install Xcode Command Line Tools. Open your terminal and run xcode-select --install. Follow the prompts to download and install the tools.

5. VS Code Configuration

VS Code is a lightweight but powerful editor. To make it a C powerhouse:

  • Open the Extensions view (Ctrl+Shift+X) and install the C/C++ extension by Microsoft. This provides IntelliSense (code completion) and debugging support.
  • Install the Code Runner extension to get a simple "Play" button to run your code instantly.
  • For advanced users: Configure tasks.json and launch.json in your .vscode folder to customize how your programs are built and debugged.

The Compilation Process: Under the Hood

What happens when you click "Run"?

  1. Preprocessing: Lines starting with # are handled. Macros are expanded, and header files are copied into your source code.
  2. Compiling: The preprocessed code is translated into Assembly language (low-level code specific to your CPU).
  3. Assembling: The Assembly code is converted into Object code (binary machine instructions but not yet a full program).
  4. Linking: Your object code is combined with library code (like the logic for printf) to create the final executable (.exe on Windows).

Common Setup Issues

  • "gcc is not recognized": Your Path variable is not set correctly or you haven't restarted your terminal after changing it.
  • Permission Denied: Your antivirus might be blocking the newly created .exe file because it's "unknown" software you just created. Try running as administrator or adding an exclusion.
If you're on a restricted computer and can't install software, use an online compiler like OnlineGDB, Ideone, or Repl.it to start coding immediately in your browser!