From the course: C: Data Structures, Pointers, and File Systems

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Using pointers to manipulate data

Using pointers to manipulate data - C Tutorial

From the course: C: Data Structures, Pointers, and File Systems

Start my 1-month free trial

Using pointers to manipulate data

- [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. And…

Contents