From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Using pointers to manipulate data

Using pointers to manipulate data - C Tutorial

From the course: Complete Guide to C Programming Foundations

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'd use pointers, but they help illustrate the concept. In this exercise file, you have two integer variables: alpha and integer pointer variable ptr. Line eight initializes variable alpha. Line nine initializes variable ptr to the address of variable alpha. This is the location where the program stores its data in memory at runtime. Both address values are output in the next two lines. The printf statement's %p conversion character displays a memory location value. The values you see output on your system will differ from those shown here, but they're identical in that they both refer to the same location in memory where variable alpha is stored. Pointers have two personalities, the second of which shows the data stored at the address. To output this information, I'll add two statements. The first will output the value of variable alpha directly…

Contents