C Programming – Day 1: Introduction & Setup


🎯 Goal: Understand the basics of C programming and set up your development environment.


1️⃣ What is C Programming?

✅ C is a general-purpose, procedural programming language developed by Dennis Ritchie in 1972.
✅ It is used in operating systems (Linux, Windows), cybersecurity, embedded systems, and game development.
✅ C is known for speed, memory management, and direct hardware interaction, making it ideal for hacking and security research.


2️⃣ Setting Up the Development Environment

For Windows Users

  1. Download MinGW (GCC Compiler)Link
  2. Install CodeBlocks IDE (optional) → Link
  3. Check installation:
    • Open Command Prompt (cmd) and type:
      gcc --version
      
    • If installed, it should show the GCC version.

For Linux/Mac Users

  1. Open Terminal and install GCC:
    sudo apt update && sudo apt install gcc  # For Ubuntu/Debian  
    sudo dnf install gcc                     # For Fedora  
    
  2. Verify installation:
    gcc --version
    

3️⃣ Writing Your First C Program

🔹 “Hello, World!” Program

Open a text editor (VS Code, CodeBlocks, or Terminal) and type:

#include <stdio.h>  // Standard Input/Output library

int main() {
    printf("Hello, World!\n");  // Print output to screen
    return 0;  // Exit the program
}

🔹 Explanation:

  • #include <stdio.h> → Includes the Standard Input/Output library.
  • int main() → Entry point of every C program.
  • printf("Hello, World!\n"); → Prints text to the screen.
  • return 0; → Ends the program successfully.

4️⃣ Compiling and Running the Program

🔹 For Windows (CMD or PowerShell)

  1. Open the folder where your C file is saved (cd path/to/folder).
  2. Compile the program:
    gcc hello.c -o hello.exe
    
  3. Run it:
    hello.exe
    

🔹 For Linux/Mac (Terminal)

  1. Navigate to the folder:
    cd path/to/folder
    
  2. Compile:
    gcc hello.c -o hello
    
  3. Run:
    ./hello
    

5️⃣ Hands-on Practice

✅ Modify the program to print your name:

#include <stdio.h>

int main() {
    printf("Hello, I am [Your Name]!\n");
    return 0;
}

✅ Try printing multiple lines:

#include <stdio.h>

int main() {
    printf("Learning C is fun!\n");
    printf("I will become a cybersecurity expert!\n");
    return 0;
}

🔹 What’s Next (Day 2)?

➡️ Learn about Variables, Data Types, and Operators in C.

Let me know if you need help setting up your environment! 🚀

Post a Comment

0 Comments