Here is where I learned pointers: https://cplusplus.com/doc/tutorial/pointers/

Once you understand pointers, pointer arithmetic is easy. The only difference between it and regular arithmetic is that the number you are adding to the pointer will be multiplied by the size of the type that the pointer is pointing to. For example, if you have a pointer to an int and an int's size is 4 bytes, (pointer_to_int + 4) will evaluate to a memory address 16 bytes (4 ints) ahead.

So when you write

(a_pointer + a_number)

in pointer arithmetic, what's really happening is

(a_pointer + (a_number * sizeof(*a_pointer)))

in regular arithmetic.

Answer from Paige Ruten on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › c language › pointer-arithmetics-in-c-with-examples
Pointer Arithmetics in C with Examples - GeeksforGeeks
Pointer arithmetic includes operations such as increment/decrement, adding or subtracting an integer, subtracting two pointers, and comparing pointers.
Published: July 11, 2026
🌐
W3Schools
w3schools.com › c › c_pointers_arithmetic.php
C Pointer Arithmetic
C Examples C Real-Life Examples ... Plan C Interview Q&A ... Pointer arithmetic means changing the value of a pointer to make it point to a different element in memory....
Discussions

c - Pointer Arithmetic - Stack Overflow
Figure the audience is a bunch ... C and C++. ... Once you understand pointers, pointer arithmetic is easy. The only difference between it and regular arithmetic is that the number you are adding to the pointer will be multiplied by the size of the type that the pointer is pointing to. For example, if you have a pointer to an int and an int's ... More on stackoverflow.com
🌐 stackoverflow.com
Why Does Pointer Arithmetic Work The Way It Does?
It is generally the behavior you want when doing arithmetic on a typed pointer. If I have T* i that points at some T then it is convenient for i + 1 to point to the T after it and i - 1 to point to the T before it. This allows a very natural syntax for accessing arrays: the ith element of an array is *(arr + i) === arr[i]. In my experience it is extremely rare that you want to do true raw arithmetic on a pointer. Doing anything that isn't an integer multiple of the base type size is just begging for unaligned accesses and other types of UB. If that is what you really want you can always cast to char* and assume the responsibility. More on reddit.com
🌐 r/C_Programming
21
12
August 6, 2021
When performing pointer arithmetic, does the type matter?
It matters, but not in an observable way, and not for reasons of pointer arithmetic, but due to complicated "integer promotion" rules. https://en.cppreference.com/w/c/language/conversion Basically: + operates on ints. If it's smaller than an signed int, it becomes signed int, otherwise other stuff happens that checks the signedness and size. So you can use whatever type you want, but just know that it's operating on int level, not e.g. uint8_t This is all legacy inherited from C and I think C++ needs to do away with it and have integer operations work on their own types. edit: Actually, I can't see a reference to pointer arithmetic and integer promotion on cppreference, so I have literally no idea if what I've said is true. Thanks C++ for being crystal clear, as always. relevant stackoverflow More on reddit.com
🌐 r/cpp_questions
15
5
May 9, 2023
Pointer Arithmetic
p++ does two things: There is a value computation, and this produces the result of the expression. This result is the value of p. There is a side effect, which is that p is incremented (i.e. it points to the "next" object of the appropriate type). When you write *(p++), the * operator is applied to the result of the p++ expression. The * operator dereferences the pointer and produces a new result: the value that the pointer was pointing at. That new result is then discarded since it is not being used in any larger expression. The side effect occurs asynchronously — that is, it is not defined when the side effect takes place while the expression is being evaluated. Nevertheless, so long as you follow the rules correctly, C will guarantee that the result of p++ will be calculated before the side effect takes place; that is, it will be the value p had immediately before any part of the expression was evaluated. The brackets are not important. Brackets do not tell C what order to evaluate things. Their purpose is just to let you write expressions that would otherwise be impossible to write given C's other syntactic rules. The order of evaluation is only governed by how the results from inner expressions are used within outer expressions. The * operation is performed after the result of the postfix ++ is calculated since it needs that result, not because of the brackets. An ordering is imposed upon the value calculations of the result of the postfix ++ operator and the result of the * operator; there is no ordering imposed upon the side effect of p++. More on reddit.com
🌐 r/cprogramming
19
3
March 30, 2024
People also ask

Can I perform arithmetic on function pointers in C?
No. Pointer arithmetic is not allowed on function pointers in C. You cannot add, subtract, or increment a function pointer because functions are not stored in contiguous memory like arrays.
🌐
wscubetech.com
wscubetech.com › resources › c-programming › pointer-arithmetic
Pointer Arithmetic in C Programming (With Examples)
Can I use pointer arithmetic with strings?
Yes. You can increment or decrement a char * to move through a string character by character.
🌐
wscubetech.com
wscubetech.com › resources › c-programming › pointer-arithmetic
Pointer Arithmetic in C Programming (With Examples)
Why does pointer arithmetic depend on data type?
Because C pointers move in steps of the size of the type they point to. This ensures accurate access to each element.
🌐
wscubetech.com
wscubetech.com › resources › c-programming › pointer-arithmetic
Pointer Arithmetic in C Programming (With Examples)
🌐
GNU
gnu.org › software › c-intro-and-ref › manual › html_node › Pointer-Arithmetic.html
Pointer Arithmetic (GNU C Language Manual)
C defines pointer subtraction to be consistent with pointer-integer addition, so that (p3 - p1) + p1 equals p3, as in ordinary algebra. Pointer subtraction works by subtracting p1’s numeric value from p3’s, and dividing by target object size.
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_pointer_arithmetic.htm
Pointer Arithmetics in C
The is why because, if the address of "x" is 1000, then it occupies 4 bytes: 1000, 1001, 1002 and 1003. Hence, the next integer can be put only in 1004 and not before it. Hence "y" (the pointer to "x") becomes 1004 when incremented.
Top answer
1 of 7
85

Here is where I learned pointers: https://cplusplus.com/doc/tutorial/pointers/

Once you understand pointers, pointer arithmetic is easy. The only difference between it and regular arithmetic is that the number you are adding to the pointer will be multiplied by the size of the type that the pointer is pointing to. For example, if you have a pointer to an int and an int's size is 4 bytes, (pointer_to_int + 4) will evaluate to a memory address 16 bytes (4 ints) ahead.

So when you write

(a_pointer + a_number)

in pointer arithmetic, what's really happening is

(a_pointer + (a_number * sizeof(*a_pointer)))

in regular arithmetic.

2 of 7
57

First, the binky video may help. It's a nice video about pointers. For arithmetic, here is an example:

int * pa = NULL;
int * pb = NULL;
pa += 1; // pa++. behind the scenes, add sizeof(int) bytes
assert((pa - pb) == 1);

print_out(pa); // possibly outputs 0x4
print_out(pb); // possibly outputs 0x0 (if NULL is actually bit-wise 0x0)

(Note that incrementing a pointer that contains a null pointer value strictly is undefined behavior. We used NULL because we were only interested in the value of the pointer. Normally, only use increment/decrement when pointing to elements of an array).

The following shows two important concepts

  • addition/subtraction of a integer to a pointer means move the pointer forward / backward by N elements. So if an int is 4 bytes big, pa could contain 0x4 on our platform after having incremented by 1.
  • subtraction of a pointer by another pointer means getting their distance, measured by elements. So subtracting pb from pa will yield 1, since they have one element distance.

On a practical example. Suppose you write a function and people provide you with an start and end pointer (very common thing in C++):

void mutate_them(int *begin, int *end) {
    // get the amount of elements
    ptrdiff_t n = end - begin;
    // allocate space for n elements to do something...
    // then iterate. increment begin until it hits end
    while(begin != end) {
        // do something
        begin++;
    }
}

ptrdiff_t is what is the type of (end - begin). It may be a synonym for "int" for some compiler, but may be another type for another one. One cannot know, so one chooses the generic typedef ptrdiff_t.

🌐
Codecademy
codecademy.com › docs › pointers › pointer arithmetics
C | Pointers | Pointer Arithmetics | Codecademy
February 3, 2025 - Pointer arithmetic in C enables operations on pointers, such as incrementing, decrementing, or finding the difference between two pointers.
Find elsewhere
🌐
Medium
medium.com › @codewithcoders96 › pointer-arithmetic-in-c-c-ca328e76943e
Pointer Arithmetic in C/C++. Pointer arithmetic is an important… | by Codewithcoders | Medium
August 7, 2024 - Pointer arithmetic is an important concept in C and C++ programming. It involves performing arithmetic operations such as addition and subtraction on pointers, allowing you to navigate through arrays and other data structures efficiently.
🌐
WsCube Tech
wscubetech.com › resources › c-programming › pointer-arithmetic
Pointer Arithmetic in C Programming (With Examples)
July 27, 2026 - Learn in this tutorial about pointer arithmetic in C with examples. Understand its use with arrays, data types, and the dos and don’ts for efficient programming.
🌐
Uncodemy
uncodemy.com › blog › pointer-arithmetic-in-c-with-examples-complete-guide
Pointer Arithmetic in C with Examples | Complete Guide
You’ll mostly use pointer arithmetic with arrays, dynamic memory, and complex data structures like linked lists and trees. - To efficiently traverse arrays and memory blocks · - To manipulate data structures such as matrices, stacks, and linked lists ... Let’s take a closer look at each of these with examples. ... When you add a number to a pointer, it moves forward by that number of elements, not bytes. ... #include <stdio.h> int main() { int arr[5] = {10, 20, 30, 40, 50}; int *ptr = arr; printf("Original address: %p\n", ptr); ptr = ptr + 2; printf("After adding 2: %p\n", ptr); printf("Value at new address: %d\n", *ptr); return 0; }
🌐
EDUCBA
educba.com › home › software development › software development tutorials › c programming tutorial › pointer arithmetic in c
Pointer Arithmetic in C | A Quick Glance of Pointer Arithmetic in C
April 20, 2023 - Pointers in C are used using the asterisk (*) operator before the name of the pointer. These addresses held by pointer variables are the integer values so the basic arithmetic operations can be performed on these pointers which will again result ...
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Scaler
scaler.com › home › topics › pointer arithmetics in c
Pointer Arithmetics in C - Scaler Topics
April 22, 2024 - In C programming, pointer arithmetic is a basic notion that allows you to manipulate memory locations contained in pointers. Understanding how to increment and decrement pointers will help you deal with data structures, arrays, and memory management ...
🌐
Reddit
reddit.com › r/c_programming › why does pointer arithmetic work the way it does?
r/C_Programming on Reddit: Why Does Pointer Arithmetic Work The Way It Does?
August 6, 2021 -

I have always found C's pointer arithmetic to be a little unintuitive.

For instance, if you have a int * that pints to 0x4 and then you add 0x1, the result will be 0x8, instead of the expected (at least for me) 0x5. This is because the value added is multiplied with the size of the base type.

Does anyone now why C does this? Especially since it has the [] operator which does the same thing, but seems more explicit. It just seems like a weird implicit behavior to tack onto the + operator. Is there any historical or technical reason?

Thank you!

🌐
GNU
gnu.org › software › c-intro-and-ref › manual › html_node › Low_002dLevel-Pointer-Arithmetic.html
Low-Level Pointer Arithmetic (GNU C Language Manual)
Here’s a function to offset a pointer value as if it pointed to an object of any given size, by explicitly performing that calculation: #include <stdint.h> void * ptr_add (void *p, int i, int objsize) { intptr_t p_address = (long) p; intptr_t totalsize = i * objsize; intptr_t new_address = p_address + totalsize; return (void *) new_address; }
🌐
Scribd
scribd.com › document › 818241163 › Pointer-Arithmetics-in-C
Pointer Arithmetic Operations in C | PDF | Pointer (Computer Programming) | Computer Science
The document explains pointer arithmetic in C, detailing operations such as incrementing, decrementing, adding, and subtracting integers to pointers, as well as comparing pointers.
🌐
Codedamn
codedamn.com › news › c programming
What is pointer arithmetic in C? How to do pointer arithmetic in C?
March 10, 2024 - It allows programmers to calculate or change addresses. This capability is particularly useful when working with arrays and dynamic memory allocation. Pointer arithmetic supports several operations, including addition, subtraction, and comparison.
🌐
YouTube
youtube.com › code with huw
Master Pointer Arithmetic In 10 Minutes (The Ultimate Guide For C Programmers). - YouTube
Pointer or address arithmetic is fundamental in C programming. In this video, I explain how to do pointer arithmetic with simple types such as ints and more ...
Published: September 18, 2024
Views: 1K
🌐
SkillVertex
skillvertex.com › blog › pointer-arithmetics-in-c-with-examples
Pointer Arithmetics In C With Examples
May 10, 2024 - When you add the integer 5 to it with the expression ptr = ptr + 5, the final address stored in ptr will be calculated as follows: 1000 + sizeof(int) * 5, which is equal to 1020. This behavior ensures that when you perform pointer arithmetic with an integer value, the pointer correctly advances by the appropriate number of bytes based on the data type’s size.
🌐
Swarthmore College
cs.swarthmore.edu › ~richardw › classes › cs31 › s18 › offsite › pointer.html
Pointer Arithmetic
That's pointer arithmetic in action. arr + 1 points to one element past arr. arr + 3 is points to 3 elements past arr. Thus, arr + i points to i elements past arr. The idea is to have arr + i point to i elements after arr regardless of what type of element the array holds. Suppose the array had contained short where a short is only 2 bytes.
🌐
Unstop
unstop.com › home › blog › pointer arithmetic in c & illegal arithmetic (+examples)
Pointer Arithmetic In C & Illegal Arithmetic (+Examples)
April 12, 2024 - Pointer arithmetic in C refers to the mathematical & comparison operations we can perform using pointers, namely decrement, increment, addition, and subtraction.