To use a pointer, it must be initialized to the address of a variable of the same data type. The ampersand operator fetches the address of a variable. Once initialized, you can use the pointer directly to reference the variable's memory location or you can prefix the asterisk, pointer, operator to manipulate the value stored at that address.
- [Instructor] To become familiar with the concept … of pointers it helps to run a few basic exercises. … These aren't the real world way you'll use pointers, … but they help illustrate the concept. … So, in this exercise file, … you see two integer variables created, … alpha, and a pointer variable, ptr. … Both are of the integer data type, … as declared in lines 5 and 6. … Line 8 initializes variable alpha, … line 9 initializes pointer variable ptr … to the address of alpha, the location … where the program stores alpha … in memory add runtime. … Both addresses are output in the next two lines, … the printf statements %p conversion character … displays a memory location value. Build and run. … Now, the values you see on your system … will be different than those show here, … but they're both identical. … In this code, the value of variable alpha … is displayed, both directly and through pointer ptr. … Line 11 uses ptr in both its modes. … First, as an address, and then … to display the contents of that address. Build and run. …
- 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.