An educational C program highlighting heap usage & how to free the memory after usage.
- Description
- Demo/Screenshots
- Features
- Tech Stack
- Project Structure
- Prerequisites
- Installation
- Usage
- Contributing
- License
The HEAP Hotel project is designed to demonstrate a simple C programming project. It specificially highlights using the heap and freeing memory after its usage.
Definition:
In C programming, the Heap (not an acronym, just a name for a "pile" of memory) is a region of your computer's RAM used for dynamic memory allocation.
Unlike the Stack, which handles local variables automatically, the Heap is a "free-for-all" area where you, the programmer, manually request and release memory during the execution of a program.
- 📚 Code Quality: The project is written in clean, readable C code, following best practices for coding standards.
- 🛠️ Modular Design: The project is structured into a single, self-contained C file, making it easy to understand and maintain.
- 📊 Performance: The project is optimized for performance, leveraging the efficiency of the C language.
- C programming language
- No frameworks or libraries are used in this project.
theHEAPHotel/
├── theHEAPHotel.c # Source code
└── screenshots/ # Screenshots folder
├── theHEAPHotel1.png
└── theHEAPHotel2.png- A C compiler (e.g., GCC) installed on the system.
- A basic understanding of C programming concepts.
To install the project, follow these steps:
git clone <repository-url>
cd theHEAPHotelNo additional installation steps are required, as the project consists of a single C file.
To compile and run the project, use the following commands:
gcc theHEAPHotel.c -o theHEAPHotel
./theHEAPHotelReplace <repository-url> with the actual URL of the repository.
Contributions are welcome and appreciated. To contribute, please fork the repository, make your changes, and submit a pull request. Ensure that your code follows the same coding standards and best practices as the existing codebase.
The theHEAPHotel project is licensed under the MIT License. See the LICENSE file for details.
Great tools I learned about along the way to help C coders:
| Tool | Purpose | When to use it |
|---|---|---|
| Valgrind | Memory Leaks | When you suspect malloc isn't being free'd (or heap/stack in general). |
| GDB | Logic Debugging | When your code runs but gives the wrong math. |
| Cppcheck | Bug Hunting | Before you even run the code. |
| ASan | Memory Crashes | To find exactly where a "Segfault" happened. |
| Flawfinder | Vulnerability Scanner | Scans code for CWE (Common Weakness Enumerations). |

