Skip to content

Latest commit

Β 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Inventory Management System in C

C Language License Status

A robust console-based Inventory Management System developed in C with file handling, data structures, and a menu-driven interface for managing products, stock levels, and sales records.

πŸ“‹ Table of Contents

✨ Features

Product Management

  • βœ… Add New Product - Add products with ID, name, category, price, quantity, and reorder level
  • βœ… View All Products - Display all products in a tabular format
  • βœ… Search Product - Search products by ID
  • βœ… Update Quantity - Update product stock levels
  • βœ… Update Price - Modify product pricing
  • βœ… Delete Product - Remove products from inventory
  • βœ… Check Low Stock - Alert when stock falls below reorder level

Inventory Management

  • βœ… View Inventory Status - Check total products and inventory value
  • βœ… Low Stock Alert - Real-time warnings for products below reorder level
  • βœ… Total Inventory Value - Calculate total worth of all products
  • βœ… Product Listing - View all products with details

Sales Management

  • βœ… Record Sale - Log product sales with automatic stock deduction
  • βœ… Sales Report - View detailed sales history with revenue calculation
  • βœ… Automatic Stock Update - Inventory updates automatically on sale
  • βœ… Sale Tracking - Each sale has unique ID and timestamp

Data Management

  • βœ… File Persistence - Data saved to text files
  • βœ… Auto-Load Data - Load existing inventory on startup
  • βœ… Cross-Platform - Works on Windows, Linux, and macOS
  • βœ… Data Validation - Input validation for all operations

πŸ“ Project Structure

Inventory-Management-System-in-C/
β”œβ”€β”€ headers/
β”‚   β”œβ”€β”€ product.h           # Product structure and operations
β”‚   β”œβ”€β”€ inventory.h         # Inventory management functions
β”‚   └── file_handler.h      # File I/O operations
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.c              # Main application with menu system
β”‚   β”œβ”€β”€ product.c           # Product implementation
β”‚   β”œβ”€β”€ inventory.c         # Inventory implementation
β”‚   └── file_handler.c      # File handling implementation
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ products.txt        # Products storage
β”‚   └── sales.txt           # Sales records
β”œβ”€β”€ README.md               # Project documentation
β”œβ”€β”€ LICENSE                 # MIT License
β”œβ”€β”€ .gitignore              # Git ignore rules
└── Makefile                # Build configuration

πŸ”§ Prerequisites

  • GCC Compiler (gcc)
  • Make utility
  • C99 Standard or later
  • Linux/Unix/Windows with terminal access

Installation

For Linux/macOS:

# Install GCC and Make
sudo apt-get install build-essential    # Ubuntu/Debian
brew install gcc make                   # macOS

For Windows:

  • Install MinGW or TDM-GCC
  • Or use WSL (Windows Subsystem for Linux)

πŸ“¦ Compilation

Option 1: Using Makefile (Recommended)

# Navigate to project directory
cd Inventory-Management-System-in-C

# Compile the project
make

# Or compile and run directly
make run

Option 2: Manual Compilation

# Create object files
gcc -Wall -Wextra -std=c99 -Iheaders -c src/main.c -o src/main.o
gcc -Wall -Wextra -std=c99 -Iheaders -c src/product.c -o src/product.o
gcc -Wall -Wextra -std=c99 -Iheaders -c src/inventory.c -o src/inventory.o
gcc -Wall -Wextra -std=c99 -Iheaders -c src/file_handler.c -o src/file_handler.o

# Link and create executable
gcc -o inventory src/main.o src/product.o src/inventory.o src/file_handler.o

Option 3: Single Command

gcc -Wall -Wextra -std=c99 -Iheaders -o inventory src/*.c

πŸš€ Usage

Run the Application

./inventory

Main Menu

╔════════════════════════════════════════════╗
β•‘   INVENTORY MANAGEMENT SYSTEM (C)         β•‘
β•‘   Version 1.0                             β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

╔════════════════════════════════════════════╗
β•‘          MAIN MENU                        β•‘
╠════════════════════════════════════════════╣
β•‘ 1. Product Management                      β•‘
β•‘ 2. Inventory Management                    β•‘
β•‘ 3. Sales Management                        β•‘
β•‘ 4. Save & Exit                             β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Example Workflow

  1. Add a Product:

    • Select: 1 (Product Management) β†’ 1 (Add New Product)
    • Enter Product ID: 101
    • Enter Name: Laptop
    • Enter Category: Electronics
    • Enter Price: 50000
    • Enter Quantity: 10
    • Enter Reorder Level: 3
  2. View All Products:

    • Select: 1 β†’ 2 (View All Products)
  3. Record a Sale:

    • Select: 3 (Sales Management) β†’ 1 (Record New Sale)
    • Enter Product ID: 101
    • Enter Quantity: 2
  4. View Sales Report:

    • Select: 3 β†’ 2 (View Sales Report)
  5. Check Inventory Status:

    • Select: 2 (Inventory Management) β†’ 1 (View Inventory Status)
  6. Save & Exit:

    • Select: 4 (Save & Exit)

πŸ“„ File Format

products.txt Format

ProductID|ProductName|Category|Price|Quantity|ReorderLevel
101|Laptop|Electronics|50000|10|3
102|Mouse|Electronics|500|50|10
103|Keyboard|Electronics|2000|25|5

sales.txt Format

SaleID|ProductID|Quantity|TotalAmount|Date&Time
1000|101|2|100000|2026-07-11 15:30:45
1001|102|5|2500|2026-07-11 15:35:20

πŸ—οΈ Technology Stack

  • Language: C (C99 Standard)
  • Paradigm: Procedural Programming
  • File Format: Text files (pipe-delimited)
  • Build System: Make
  • Compiler: GCC
  • Platform: Cross-platform (Linux, macOS, Windows)

πŸ“Š Key Data Structures

Product Structure

typedef struct {
    int productID;
    char name[50];
    char category[30];
    float price;
    int quantity;
    int reorderLevel;
} Product;

Inventory Structure

typedef struct {
    Product products[100];
    int totalProducts;
} Inventory;

Sale Structure

typedef struct {
    int saleID;
    int productID;
    int quantity;
    float totalAmount;
    char date[20];
} Sale;

🎯 Functions Overview

Product Management

  • addProduct() - Add new product
  • displayProduct() - Show single product
  • displayAllProducts() - Show all products
  • findProductByID() - Search by ID
  • updateProductQuantity() - Update stock
  • updateProductPrice() - Update price
  • deleteProduct() - Remove product
  • checkLowStock() - Stock alerts

Inventory Management

  • initializeInventory() - Initialize
  • displayInventoryStatus() - Show status
  • getInventoryValue() - Calculate value
  • displayLowStockAlert() - Show alerts

Sales Management

  • recordSale() - Record sale
  • displaySalesReport() - Show report

File Operations

  • saveProductsToFile() - Save products
  • loadProductsFromFile() - Load products
  • saveSaleToFile() - Save sale
  • loadSalesFromFile() - Load sales

πŸ› οΈ Makefile Commands

make          # Compile the project
make run      # Compile and run
make clean    # Remove build files
make rebuild  # Clean and rebuild
make help     # Show all commands

πŸ› Troubleshooting

Issue: "gcc not found"

Solution: Install GCC compiler for your OS

Issue: "Permission denied" when running

Solution: Make file executable

chmod +x inventory

Issue: "data directory not found"

Solution: The program creates it automatically. If not, manually create:

mkdir -p data

Issue: "File not found" error

Solution: Ensure you run from the project root directory

πŸ“ Sample Test Cases

  1. Add Products β†’ View β†’ Search
  2. Update Quantity β†’ Record Sale β†’ Verify Stock
  3. View Sales Report β†’ Check Revenue
  4. Low Stock Alert β†’ Reorder Check
  5. Save Data β†’ Restart β†’ Load Data

πŸŽ“ Learning Outcomes

  • Proficiency in C programming
  • Understanding of data structures (structs, arrays)
  • File I/O operations in C
  • Menu-driven application design
  • Real-world business logic implementation
  • Cross-platform development
  • Build system usage (Makefile)
  • Software architecture and modularity

πŸš€ Future Enhancements

  • Database integration (SQLite)
  • User authentication
  • Advanced reporting (PDF/CSV export)
  • Graphical UI (GTK+/Qt)
  • Multi-user support
  • Network capability
  • Backup/Restore feature
  • Data encryption

🀝 Contributing

Contributions are welcome! Feel free to:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

πŸ“§ Contact

Author: Deepak Kumar
GitHub: @deepaksaranay
Email: deepakkumar.dar@gmail.com
LinkedIn: linkedin.com/in/deepak-kumar-083448115

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file for details.

⭐ Acknowledgments

  • C programming best practices
  • Data structure design patterns
  • File handling techniques
  • Cross-platform development

Made with ❀️ by Deepak Kumar

Last Updated: July 2026

About

A console-based Inventory Management System developed in C with file handling, data structures, and a menu-driven interface for managing products, stock levels, and sales records.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages