Skip to content

deepaksaranay/Inventory-Management-System-in-C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors