Incrementing a pointer variable's address increases its value by the size of the data type the pointer references. To assign a pointer the address of an array, the ampersand isn't required. Incrementing a pointer referencing an array, sets the pointer to the next element in the array. The sizeof operator obtains the number of bytes used by a variable stored in memory.
- [Instructor] A pointer is a variable … that holds a memory location. … So, what happens when you add one to that variable? … And I'm referring to the pointer variable … as an address, without the asterisk. … As an example in this exercise file you see pointer "pa" … initialized to the address of variable "alpha" in line 8. … Both are integer variables. Line 9 displays the address … stored in pa, and line 10 displays that address plus 1. … Build and run. … Now, using my best hexadecimal math … I can tell you that these two values differ by 4 bites. … 8 is 4 bites away from C. … Adding 1 to the address stored in pa … Increased that address by 4 bites. … By the way, at this point in line 10 … the pointer references some unknown chunk of memory … this unsafe coding practice, but I did it here … to illustrate a point. … Here's a better example. … In this exercise file aray twos is defined … and pointer pt is set to the base address … of the array at line 8. … No ampersand is required with this assignment …
- Working with arrays
- Building a structure
- Creating an array of structures
- Testing characters
- Working with strings in C
- Using pointers to manipulate data
- Manipulating files
- Using command-line arguments
- Working with time functions
Skill Level Intermediate
1. Arrays and Structures
2. Characters and Strings
4. Files and the Operating System
5. The Interesting and Extraordinary
Next steps1m 52s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.