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 - 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
-
-
-
-
-
-
-
-
-
-
Understanding pointers3m 23s
-
(Locked)
Using pointers to manipulate data2m 53s
-
(Locked)
Doing pointer math3m 10s
-
(Locked)
Comparing arrays and pointers5m 5s
-
(Locked)
Challenge: Output a string57s
-
(Locked)
Solution: Output a string2m 44s
-
(Locked)
Allocating storage3m 42s
-
(Locked)
Working with a pointer array4m
-
(Locked)
Using pointers in structures3m 8s
-
(Locked)
Challenge: Allocating structures1m 3s
-
(Locked)
Solution: Allocating structures3m 34s
-
(Locked)
Passing pointers to functions2m 23s
-
(Locked)
Returning pointers from a function2m 31s
-
Chapter challenge: Processing input1m 26s
-
(Locked)
Chapter solution: Processing input3m 14s
-
-
-
-