From the course: Master C Language Pointers
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Solution: Obtain an address - C Tutorial
From the course: Master C Language Pointers
Solution: Obtain an address
(upbeat music) - [Instructor] Here's my solution, which uses the four variables a, x, b, and y, two of them characters, two of them integers, and two of them pointers all declared on lines five and six. Lines eight and nine output the addresses of variables a and b. The ampersand operator is used on both, and their %p placeholder. The pointer variables are initialized to variables a and b's addresses in lines 10 and 11. Again the ampersand operator is used to obtain those addresses. Then the addresses, stored in the pointers, are output at lines 12 and 13. No ampersand is needed. No asterisk operator is needed, as the pointers hold the address themselves. Build and run. And you see the address is output, and they match: a to a and b to b. I hope your solution worked the same way. It need not look exactly like mine, but as long as you use the operators and variables correctly, congratulations.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.