"The only way to learn a new programming language is by writing programs in it." — Dennis Ritchie
Welcome to the digital archive of my C programming journey! This repository contains a structured, modular log of my 1st-semester coding progress, ranging from the fundamental printf("Hello, World!"); to advanced system concepts like memory management, file handling, and custom macros.
This project has been restructured to offer a clean, educational roadmap for anyone exploring the foundations of computer science and C systems programming.
The codebase is organized chronologically and conceptually into 11 modules:
Sea of C/
│
├── 01_Introduction/ # First C Program & Structure
├── 02_Data_Types_Operators/ # Variables, Operators, Precedence
├── 03_Control_Flow/ # Conditionals, Loops, & Pattern Printing
├── 04_Functions/ # Scope, Modular Code, & Recursion
├── 05_Arrays_and_Strings/ # 1D/2D Arrays, Sorting, & Safe String Handling
├── 06_Pointers/ # Addresses, Pointer Arithmetic, & Void/Dangling Pointers
├── 07_Structures_Unions_Enums/ # Custom Structs, Unions, & Enum Types
├── 08_Dynamic_Memory_Allocation/ # Heap Allocation (malloc, calloc, realloc, free)
├── 09_File_Handling/ # File I/O Operations (Text & Binary)
├── 10_Preprocessors_and_Macros/ # Preprocessors, Macros, Header Guards, & CLA
└── 11_Mini_Projects/ # Interactive Console Games
- Concepts: C program skeleton, headers (
#include), entry point (main), return status codes, and standard output (printf). - Theory: Basic Structure Explanation.
- Core Files: basic_structure.c.
- Concepts: Format specifiers (
%d,%f,%c), type qualifiers, variable scoping, arithmetic/bitwise/logical/relational operators, and associativity. - Theory:
- Practice: Practice Problems (RideShare Bonus Points, temperature conversion, and arithmetic challenge).
- Concepts: Decision making (
if,else if,switch-case, ternary operator) and iterative execution (for,while,do-while, nested loops). - Sub-folders:
branching/: Conditionals and calculators. Theory: Branching Basics.loops/: Loop syntax, input validation, digit sum, and loop exercises.pattern_printing/: Multi-loop grid printing, star/number triangles, and diamond grids.
4. 04_Functions
- Concepts: Modular program design, parameters passing, call-by-value vs. call-by-reference, function prototypes, and recursion.
- Theory: Recursion Explanation & Call Stack Diagrams.
- Core Files: recursion_basics.c, writing_functions.c.
- Concepts: Continuous memory storage, array traversal, Selection Sort, string manipulation, and safe buffer handling.
- Sub-folders:
arrays/: 1D & 2D arrays, finding min/max, duplicates tracking, reversing arrays, and sorting.strings/: Safe input handling viafgets()(avoiding buffer overflows), string library functions (strlen,strcpy,strcat,strcmp).
6. 06_Pointers
- Concepts: Memory addresses, pointer arithmetic, double pointers (
int**), character pointer arrays, null pointers, void pointers, and dangling pointers. - Core Files:
- Concepts: User-defined complex types, structure sizing (padding & packing), struct arrays, unions (sharing memory), and enums (named integer constants).
- Theory:
- Core Files: struct_basic.c, union.c.
- Concepts: Heap memory lifecycle, runtime allocation, memory leak prevention, and dynamic multi-dimensional arrays.
- Theory: Why Dynamic Memory Allocation (DMA).
- Core Files:
- malloc / calloc / free / realloc demos
- dynamic_2d_array.c (dynamic double-pointers).
- Concepts: Stream files, character/string I/O (
fgetc,fputc,fgets,fputs), block binary I/O (fread,fwrite), and EOF marker detection. - Core Files:
- 01_basic.c
- struct_file_io.c (writing records to binary files).
- Data: All read/write files are stored inside the centralized
/datadirectory.
- Concepts: Macro expansion, stringification, token pasting, header guards, and arguments passed to
main(argc,argv). - Theory & Guides:
- Core Files:
11. 11_Mini_Projects
- Guess the Number:
- Path: guess_the_number.c
- Rules: The computer selects a random number, and the player tries to guess it. The game records the number of attempts and gives hints ("higher" or "lower").
- Snake Water Gun (Rock Paper Scissors Variant):
- Path: snake_water_gun.c
- Rules: An interactive round-based game played against the computer. Evaluates choices (Snake beats Water, Water beats Gun, Gun beats Snake) and counts scores.
To compile any program in this repository, make sure you have gcc (MinGW for Windows) installed.
Open a terminal in the folder containing the source file and run:
# Compile
gcc program_name.c -o program_name.exe
# Run
./program_name.exe- Install the C/C++ extension by Microsoft.
- Open the directory in VS Code.
- Use
Ctrl + Shift + Bto build, or run using the terminal.
- Open Code::Blocks.
- Select File -> Open... and select the
.cfile. - Click the Build and Run button (or press
F9).
- Badhon Pain — Repository owner and Maintainer.
- "The C Programming Language" (K&R) by Brian W. Kernighan and Dennis M. Ritchie — served as the foundational textbook guide for learning standard C programming practices, concepts, and conventions.
- Prof. Dr. AKM Ashikur Rahman (Department of CSE, BUET) — who instructed our class and whose lectures and course slides provided the core curriculum, educational framework, and structured examples followed throughout this journey.