Skip to content

AshutoshKumar7001/Departmental-Store-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Departmental Store Management System (DSMS)

This directory contains the C implementation of the Departmental Store Management System (DSMS).

Table of Contents

Project Overview

This is a C-based departmental store management system. The code here is implemented in C source files (.c) with headers (.h). Build automation is done via a Makefile (recommended). The produced executable (by default) is dsms (can be changed in Makefile).

Prerequisites

  • A POSIX-like environment (Linux, macOS, WSL on Windows). Windows users can use MinGW/MSYS2 or WSL.
  • C compiler (gcc or clang). Minimum recommended: gcc supporting C11.
  • make (GNU Make) for using the Makefile (optional but recommended).

Optional:

  • Any third-party libraries the project depends on (if any). If the project uses external libs, add them to LDFLAGS in the Makefile.

Repository layout

This README focuses on the contents of: DSMS/CUT/Code/DSMS/

Typical files:

  • *.c — C source files
  • *.h — header files
  • Makefile — build rules
  • bin/ — recommended output directory for executables (created by Makefile)
  • README.md — this file

Adjust paths below if your sources are in subfolders.

Quick start

  1. Open a terminal and navigate to the DSMS directory:
    cd DSMS/CUT/Code/DSMS
  2. Build using make:
    make
    This will produce the executable (default: bin/dsms).
  3. Run:
    ./bin/dsms

If make or the Makefile is unavailable, see the "Build manually" section.

Makefile — build automation

A Makefile is recommended because it automates compilation, linking, cleaning, and debug builds.

How to use the provided Makefile

Common targets:

  • make or make all: Build the project (default).
  • make run: Build then run the main executable.
  • make debug: Build with debug flags (-g -O0) for use with a debugger.
  • make clean: Remove object files and binaries.

Example:

# Build
make

# Build with debug symbols
make debug

# Run the app
make run

# Clean build artifacts
make clean

How to create the Makefile (if missing)

  1. Create a file named Makefile in this directory.
  2. Paste the example Makefile below and save.
  3. Adjust variables:
    • TARGET — desired executable name.
    • SRCDIR — path to your .c files (default .).
    • CFLAGS and LDFLAGS — compiler and linker flags.
  4. Run make.

Example Makefile

Create a file named Makefile and paste the content below. This is a flexible template that discovers .c files in the source directory and produces the binary in bin/.

# Simple/portable Makefile for C projects

CC      := gcc
SRCDIR  := .
BINDIR  := bin
TARGET  := dsms

CFLAGS  := -std=c11 -Wall -Wextra -O2
DEBUGFLAGS := -g -O0
LDFLAGS :=

SRCS    := $(wildcard $(SRCDIR)/*.c)
OBJS    := $(SRCS:.c=.o)

.PHONY: all clean debug run

all: $(BINDIR)/$(TARGET)

# Link
$(BINDIR)/$(TARGET): $(OBJS) | $(BINDIR)
	$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)

# Create bin directory if needed
$(BINDIR):
	mkdir -p $(BINDIR)

# Compile .c -> .o
%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

# Debug build (adds debug flags)
debug: CFLAGS += $(DEBUGFLAGS)
debug: clean all

# Run (builds first)
run: all
	./$(BINDIR)/$(TARGET)

clean:
	rm -f $(SRCDIR)/*.o $(BINDIR)/$(TARGET)

Notes:

  • Recipe lines must start with a TAB character (not spaces).
  • If your project has subdirectories for sources, adjust SRCS (e.g., $(wildcard src/*.c src/modules/*.c)).
  • To link against libraries (e.g., -lm, -lncurses, -lsqlite3), add them to LDFLAGS, e.g. LDFLAGS := -lm -lsqlite3.

Build and run manually (without make)

If you prefer a one-line compilation or don't have make:

Single file:

gcc -std=c11 -Wall -Wextra -O2 -o dsms main.c
./dsms

Multiple files:

gcc -std=c11 -Wall -Wextra -O2 -o dsms file1.c file2.c file3.c
./dsms

With debug symbols:

gcc -std=c11 -Wall -Wextra -g -O0 -o dsms *.c
gdb ./dsms

Cleaning build artifacts

If you used the example Makefile:

make clean

Manually:

rm -f *.o bin/dsms

Debugging & development tips

  • Build with make debug to include -g and disable optimizations for easier debugging.
  • Use gdb or lldb:
    gdb ./bin/dsms
  • Use valgrind to catch memory issues:
    valgrind --leak-check=full ./bin/dsms
  • Add -DDEBUG to CFLAGS (or use DEBUGFLAGS) to enable debug-only code paths in your sources.

Adding a new source file

  1. Add the .c and any .h files to the directory.
  2. If using the example Makefile, it will automatically pick up *.c files.
  3. Re-run make.

If your new source belongs in a subdirectory, update SRCS in the Makefile:

SRCS := $(wildcard src/*.c src/modules/*.c)

Coding style & conventions

  • Prefer modularization: put declarations in header files (.h) and definitions in source files (.c).
  • Use guards in headers:
    #ifndef ITEM_H
    #define ITEM_H
    /* declarations */
    #endif // ITEM_H
  • Compile with warnings enabled (-Wall -Wextra) and treat warnings seriously.
  • Use meaningful variable/function names and comment non-obvious logic.

Notes and troubleshooting

  • If mkdir -p in the Makefile fails on native Windows cmd.exe, either create the bin directory manually or run make inside an MSYS/MinGW or WSL shell which supports mkdir -p.
  • If you need external libraries, install them and update LDFLAGS and possibly CFLAGS (include paths -I/path/to/include).
  • If compilation fails due to standards, try switching -std=c11 to -std=c99 or remove the standard flag temporarily.

Author

Ashutosh Kumar

  • Passionate about building smart, automated solutions for real-world problems.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors