Uploaded November 2026 | Updated December 2026, 3 hours ago
Learn how Pointer Arithmetic works in C programming and understand how to use Addition, Subtraction, Increment, and Decrement operations with Pointers.
In this beginner-friendly tutorial, we first introduce Pointer Arithmetic and discuss the arithmetic operations that can be performed on pointers in C.
We explain how adding or subtracting an integer from a pointer generates a pointer value referring to a different element within an array.
Using an Integer Array containing 10, 20, 30, and 40, we demonstrate how Pointer Arithmetic works with Array Elements and Memory Addresses.
Next, we explain why Pointer Arithmetic depends on the type of object a pointer points to.
For example, when we add 1 to a Pointer to int, the resulting pointer refers to the next integer element, not simply the next byte in memory.
We compare Pointer Arithmetic with int * and char * pointers to demonstrate how the pointer type determines the number of bytes between consecutive elements.
After that, we explore Pointer Addition and Subtraction using expressions such as:
1. ptr + 1
2. ptr + 2
3. ptr - 1
4. ptr + 0
We explain how these expressions generate pointer values relative to the element currently pointed to by ptr.
Next, we combine Pointer Arithmetic with Pointer Dereferencing to access and modify Array Elements.
Using expressions such as *(ptr + 1) and *(ptr + 3), we demonstrate how to read and modify values stored in an Integer Array.
We then explore the relationship between Array Indexing and Pointer Arithmetic.
We compare the following expressions:
1. numbers[1]
2. *(numbers + 1)
3. ptr[1]
4. *(ptr + 1)
We demonstrate how these expressions access the same Array Element when ptr points to the first element of numbers.
Next, we explain why Array Indexing starts at zero and how the Array Subscript Operator [] works using Pointer Arithmetic.
We also explore an interesting feature of C: expressions such as 1[ptr] and 1[numbers] are valid because Pointer Addition allows both ptr + 1 and 1 + ptr.
However, we explain why Subtraction is different and why an expression such as 1 - ptr is not valid.
After that, we discuss the difference between generating a new Pointer Value and modifying the value stored in a Pointer Variable.
We demonstrate how ptr + 1 produces a pointer value without changing ptr, while ptr = ptr + 1 updates the pointer variable.
Next, we explain why standard C does not allow Pointer Arithmetic directly on void * pointers, since void does not provide a complete object type for determining element sizes.
Finally, we explore Pointer Increment and Decrement operations using ptr++, ++ptr, ptr--, and --ptr.
We explain how these operations update the pointer variable so that it refers to the next or previous Array Element.
This tutorial helps you understand Pointer Arithmetic, Pointer Addition, Pointer Subtraction, Array Indexing, Pointer Dereferencing, Pointer Increment and Decrement, and Memory Addresses in C programming.
Our Website
LearningLad.com
Social Media
Facebook facebook.com/LearningLad
Twitter twitter.com/LearningLadEdu
Instagram instagram.com/LearningLadOfficial
Learn how Pointer Arithmetic works in C programming and understand how to use Addition, Subtraction, Increment, and Decrement operations with Pointers.
In this beginner-friendly tutorial, we first introduce Pointer Arithmetic and discuss the arithmetic operations that can be performed on pointers in C.
We explain how adding or subtracting an integer from a pointer generates a pointer value referring to a different element within an array.
Using an Integer Array containing 10, 20, 30, and 40, we demonstrate how Pointer Arithmetic works with Array Elements and Memory Addresses.
Next, we explain why Pointer Arithmetic depends on the type of object a pointer points to.
For example, when we add 1 to a Pointer to int, the resulting pointer refers to the next integer element, not simply the next byte in memory.
We compare Pointer Arithmetic with int * and char * pointers to demonstrate how the pointer type determines the number of bytes between consecutive elements.
After that, we explore Pointer Addition and Subtraction using expressions such as:
1. ptr + 1
2. ptr + 2
3. ptr - 1
4. ptr + 0
We explain how these expressions generate pointer values relative to the element currently pointed to by ptr.
Next, we combine Pointer Arithmetic with Pointer Dereferencing to access and modify Array Elements.
Using expressions such as *(ptr + 1) and *(ptr + 3), we demonstrate how to read and modify values stored in an Integer Array.
We then explore the relationship between Array Indexing and Pointer Arithmetic.
We compare the following expressions:
1. numbers[1]
2. *(numbers + 1)
3. ptr[1]
4. *(ptr + 1)
We demonstrate how these expressions access the same Array Element when ptr points to the first element of numbers.
Next, we explain why Array Indexing starts at zero and how the Array Subscript Operator [] works using Pointer Arithmetic.
We also explore an interesting feature of C: expressions such as 1[ptr] and 1[numbers] are valid because Pointer Addition allows both ptr + 1 and 1 + ptr.
However, we explain why Subtraction is different and why an expression such as 1 - ptr is not valid.
After that, we discuss the difference between generating a new Pointer Value and modifying the value stored in a Pointer Variable.
We demonstrate how ptr + 1 produces a pointer value without changing ptr, while ptr = ptr + 1 updates the pointer variable.
Next, we explain why standard C does not allow Pointer Arithmetic directly on void * pointers, since void does not provide a complete object type for determining element sizes.
Finally, we explore Pointer Increment and Decrement operations using ptr++, ++ptr, ptr--, and --ptr.
We explain how these operations update the pointer variable so that it refers to the next or previous Array Element.
This tutorial helps you understand Pointer Arithmetic, Pointer Addition, Pointer Subtraction, Array Indexing, Pointer Dereferencing, Pointer Increment and Decrement, and Memory Addresses in C programming.
Our Website
LearningLad.com
Social Media
Facebook facebook.com/LearningLad
Twitter twitter.com/LearningLadEdu
Instagram instagram.com/LearningLadOfficial








![String Literals in C Explained | Memory Storage, Pointers & Undefined Behavior
Learn how String Literals work in C programming, where they are stored in memory, how to create pointers to them, and why modifying a String Literal causes Undefined Behavior.
In this beginner-friendly tutorial, we explore the relationship between String Literals, Character Arrays, Pointers, and Memory Storage in C.
We begin by reviewing how Character Arrays can be initialized using String Literals such as hello and world.
Next, we explain what a String Literal is in C programming.
A String Literal is a sequence of characters enclosed in double quotation marks. We also discuss how the Null Terminator (0) is included at the end of the character sequence.
For example, the String Literal hello contains five visible characters and requires six array elements, including the Null Terminator.
After that, we explore where String Literals are stored in memory.
We explain how String Literals form part of the program data and discuss how they are represented in an executable program.
Using a conceptual Process Memory Layout, we review the Code or Text Region, Data and BSS Regions, Heap, and Stack.
We then explain how String Literals have Static Storage Duration and remain available throughout the entire execution of the program.
We also discuss why the exact memory region used to store String Literals depends on the compiler and implementation.
Next, we compare Character Arrays initialized with String Literals and Pointers that directly refer to String Literals.
For example:
char text[] = hello;
const char *ptr = world;
We explain how text is a separate modifiable Character Array, while ptr points to the first character of a String Literal.
We demonstrate how modifying an element of text changes the Character Array without modifying the original String Literal.
After that, we discuss why String Literals must not be modified in C programming.
Even though C permits a String Literal to initialize a char * pointer, attempting to modify the String Literal through that pointer results in Undefined Behavior.
We explain why using const char * is a better practice when working with String Literals.
Next, we compare Pointer to const and Const Pointer declarations.
We explore how const char *ptr provides read-only access through the pointer, while const char *const ptr also prevents the pointer variable from being reassigned.
After that, we demonstrate how to return a String Literal from a function.
We create a get_message() function that returns const char * and explain why returning a pointer to a String Literal is valid because String Literals have Static Storage Duration.
Finally, we explore what happens when the same String Literal appears multiple times in a C program.
Using two pointers initialized with hello, we display their pointer values using printf() and the %p Format Specifier.
We discuss String Literal Pooling and explain why identical String Literals may share the same memory location or may be stored separately, depending on the implementation.
This tutorial helps you understand String Literals, Static Storage Duration, Character Arrays, Pointers to String Literals, const char *, Undefined Behavior, Process Memory Layout, and String Literal Pooling in C programming.
Our Website
https://www.LearningLad.com
Social Media
Facebook https://www.facebook.com/LearningLad
Twitter https://www.twitter.com/LearningLadEdu
Instagram https://www.instagram.com/LearningLadOfficial String Literals in C Explained | Memory Storage, Pointers & Undefined Behavior](https://i.ytimg.com/vi/UPAqzQNm5bg/mqdefault.jpg)

