Join Dan Gookin for an in-depth discussion in this video When to use the ampersand operator, part of Advanced C Programming.
- If you really want to get down and dirty…with pointers in C,…you need to embrace two unary operators,…the ampersand and the asterisk.…This movie covers the ampersand.…A later movie covers the asterisk.…Also, of the two, the ampersand causes less trouble,…although it can be confusing.…The ampersand is the address of operator.…It returns the memory location of a variable,…and that's the only way it's used,…prefixed to a variable like the engine on a train.…The variable doesn't even have to be initialized,…just declared.…
Open exercise 05-01_ampersand1.…This code declares four variables,…a, b, c, and d,…each of a different type.…When a variable is declared,…it's given a location in memory.…To fetch that address, you use the ampersand operator.…The printf statement displays those addresses.…The %p placeholder is used…and the & fetches the address.…Build and run this code.…The addresses you see on your screen…will be different from what you see here.…
Each computer shows not only a different location,…but perhaps a different format for the numbers.…
Author
Released
1/15/2015- Using assignment operators
- Working with arguments in the main function
- Setting up global variables
- Using static variables
- Sorting an array
- Building an array of structures
- Working with the ampersand (&) and asterisk (*) pointer operators
Skill Level Intermediate
Duration
Views
Related Courses
-
C Essential Training
with Isac Artzi7h 22m Beginner -
Learning C++
with Peggy Fisher2h 36m Beginner -
Learning C
with Dan Gookin3h 28m Beginner -
C++ Essential Training
with Bill Weinman7h 48m Intermediate
-
-
Welcome56s
-
-
Introduction
-
1. C Programming: Weird-Symbol Roundup
-
Using assignment operators3m 41s
-
-
2. Main Function Arguments
-
3. Beyond Basic Variables
-
Typecasting variables4m 46s
-
4. Arrays and Structures
-
Sorting an array6m 39s
-
Solution: Sorting a string1m 25s
-
-
5. Pointer Tips
-
Conclusion
-
Next steps1m 49s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: When to use the ampersand operator