cplusplus:pointers_3_slides
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
cplusplus:pointers_3_slides [2019/03/31 21:42] – mithat | cplusplus:pointers_3_slides [2021/10/24 02:46] (current) – [Pointer arithmetic: addition] mithat | ||
---|---|---|---|
Line 6: | Line 6: | ||
Pointers, arrays, arithmetic.\\ | Pointers, arrays, arithmetic.\\ | ||
Mithat Konar\\ | Mithat Konar\\ | ||
- | March 31, 2019 | + | October 23, 2021 |
===== Pointers and arrays ===== | ===== Pointers and arrays ===== | ||
* Arrays and pointers are closely related. | * Arrays and pointers are closely related. | ||
- | * An array name is like a constant | + | * Array names are like a constant |
* the block of memory where an array name points cannot be changed, | * the block of memory where an array name points cannot be changed, | ||
* what is stored there can change. | * what is stored there can change. | ||
Line 51: | Line 51: | ||
===== Pointer arithmetic ===== | ===== Pointer arithmetic ===== | ||
- | * Pointer arithmetic works differently | + | * Pointer arithmetic works differently |
* '' | * '' | ||
* E.g., adding 1 to a pointer makes it point to the next block of memory corresponding to the size of the underlying type. | * E.g., adding 1 to a pointer makes it point to the next block of memory corresponding to the size of the underlying type. | ||
+ | |||
<file cpp pointer-math.cpp> | <file cpp pointer-math.cpp> | ||
Line 78: | Line 79: | ||
</ | </ | ||
- | ===== Pointer arithmetic ===== | + | ===== Pointer arithmetic: pointer difference |
Subtracting one pointer from another returns the number of elements between two addresses: | Subtracting one pointer from another returns the number of elements between two addresses: |
cplusplus/pointers_3_slides.1554068557.txt.gz · Last modified: 2019/03/31 21:42 by mithat