This repository contains small educational projects in the C programming language, focusing on the use of struct types to build interactive command-line applications. The programs include data structures like queues and game logic implementations such as Hangman and a simple turn-based strategy game.
Each project demonstrates key concepts in procedural programming, dynamic memory allocation, and user-driven design.
This project implements a simplified version of the classic Hangman word-guessing game in C.
- Player 1 inputs a secret word.
- The screen is cleared and Player 2 tries to guess the word, one letter at a time.
- For each wrong guess, the remaining attempts counter decreases.
- If a guessed letter exists in the word, it is revealed in its correct positions.
- The game ends when:
- All letters are guessed correctly ✅
- The player runs out of attempts ❌
- Converts all input characters to lowercase.
- Checks for repeated guesses and informs the user.
- Clears screen with
system("cls")orsystem("clear")depending on OS. - Uses a helper function to check letter existence in word.
- C compiler (e.g.
gcc) - Runs on Linux/Windows
gcc hangman_game.c -o hangman_game
./hangman_game
This project implements a FIFO (First-In-First-Out) Queue using a singly linked list in C.
The program defines a struct node and allows the user to perform queue operations via a menu:
Insert: Add a new element to the end of the queue.Delete: Remove and return the element at the front of the queue.GetNth: Retrieve the value at a specific position in the queue.Count: Count how many times a specific value appears in the queue.
Insert
Delete
Get-Nth
Count
Exit
gcc linked_queue.c -o linked_queue
./linked_queue
This project simulates a simplified two-player turn-based strategy game in C, involving unit purchasing, resource management, and combat strength.
A unit structure holds attributes like name, attack power, cost, upkeep, and quantity owned.
Each player takes turns to buy units (e.g. Peon, Grunt, Troll).
Workers generate money, military units consume money and increase attack power.
The game tracks each player’s money and army power.
Victory is achieved when one player has:
Significantly more army power, or
Accumulated enough money.
Initialization of unit types (can be read from file).
Two arrays of units, one for each player.
Turn-based input loop for unit purchases.
Dynamic tracking of total money and army strength.
Money-based or army-based win.
Game ends immediately upon victory condition met.
gcc strategy_game.c -o strategy_game
./strategy_game