What is the difference between const pointer and pointer to const in C ?

In C programming, pointers are fundamental tools that allow direct manipulation of memory. However, when combined with the const qualifier, they can introduce subtle distinctions that often confuse both beginners and seasoned developers. At first glance, the terms const pointer and pointer to const might seem interchangeable, but they serve different purposes. This article explores […]

Optimizing Enum Storage in C with -fshor-enum flag

When working with C, efficiency in memory usage can be a critical factor, especially in embedded systems or low-level programming. One lesser-known yet powerful GCC compiler flag that can help optimize storage is -fshort-enums. This flag changes the way the compiler allocates memory for enumerations (enum), potentially reducing the size of compiled code. In this […]

Naming convention in C

In the world of C programming, the clarity and maintainability of your code often hinge on a seemingly simple yet crucial aspect: naming conventions. From variables to functions, constants to macros, the names you choose can significantly impact how easily others (and your future self) understand and work with your code. While the C language […]

Function Prototype in C

This article delves into the concept of function prototypes in C, exploring their syntax, purpose, and benefits. Whether you’re a beginner learning the fundamentals or an experienced programmer looking to refine your understanding, mastering function prototypes is a foundational step toward writing efficient and maintainable C programs. In the C programming language, a function prototype […]

Single point of exit

Using a single point of exit in C (or other programming languages) is often considered good practice because it improves code readability and maintainability, and reduces the likelihood of bugs. In this article, we’ll take a deep dive into this topic to see if it’s really true.

Why C strlen function is considered as not safe

n the world of programming, writing secure and efficient code is a constant challenge, especially when working with low-level languages like C. C provides developers with powerful tools, but with great power comes great responsibility. Among these tools is the strlen function, a staple of string manipulation in C. While seemingly simple and straightforward, improper use of strlen can lead to unexpected behavior, performance issues, and even critical security vulnerabilities. This article explores the potential pitfalls of using strlen, why it’s considered unsafe in certain situations, and how developers can adopt safer practices to protect their applications.

What is referencing and dereferencing in C

This article is intended for the novice programmer who wants to understand the concept of referencing and dereferencing data in the C programming language. I will try to explain it as simply as possible, using some simple and easy to understand examples. To fully understand the topic, it is worth looking at some introduction to […]

Stack, heap and memory management in microcontrollers

In this article I’ll do my best to explain as simply as possible how memory management in microcontrollers works, what are „stack” and „heap” areas, and what’s the difference between them. Let’s start with a general diagram presenting how „uC” RAM memory is divided into diffrent arreas: Starting from the bottom, which is the beginning […]

What is function prototype in C

In C language function prototype is just information for the compiler about the existence of a function. It also provides basic information about its name, returning type, and list of accepted arguments. Let’s see it in an example: #include <stdio.h>void print_hello_msg(void); // This is prototype for the print_hello_msg functionint main(){ print_hello_msg(); return 0;}void print_hello_msg(void){ printf(„Hello […]