This document provides a comprehensive solution to a C programming assignment. The first part focuses on identifying and correcting errors in a given C code snippet, including issues with include statements, array sizes, and loop conditions. The second part delves into memory allocation, exploring how memory is allocated using `malloc` and analyzing the potential for buffer overflow vulnerabilities. The third section examines normal and abnormal program runs, specifically addressing segmentation faults caused by invalid user input. The fourth part analyzes a code snippet related to format string vulnerabilities, explaining how an attacker can manipulate memory addresses. Finally, the fifth part discusses security principles, including the Principle of Least Privilege and TOCTOU (Time-Of-Check to Time-Of-Use) vulnerabilities, providing examples of how these principles apply in password management systems and file I/O operations, and discussing how to mitigate these vulnerabilities. The assignment covers topics relevant to computer security, software development, and memory management.