Join Dan Gookin for an in-depth discussion in this video Allocating memory, part of Learning C (2014).
- When a program needs storage, you allocate it…in the code by setting aside space for a variable.…When you need more than one variable, you create an array.…And when you don't know how much space you need, you guess.…But there's a better way.…In this movie, I cover the topic…of allocating storage in your code.…You'll see how to properly ask for storage,…determine that it's available,…and then access that storage in your code.…Storage is divvied up by the operating system.…
Your program asks for space as it needs it.…This request is made in one of two ways.…The first way is to declare a variable.…Storage for the variable is set aside…and made available for use.…And for a specific purpose in the code.…This code declares several variable types.…Including an empty character buffer.…The sizeof operator is then used to calculate…how much storage is set aside.…Build and run this code.…On my computer, it shows that 141 bytes…of storage were set aside.…
Even though the storage is never used,…save for the total variable, it's still set aside.…
- Understanding a C program
- Adding comments
- Using escape characters
- Working with values and placeholders
- Introducing variables
- Making a decision with if
- Adding functions
- Manipulating strings
- Building arrays
- Nesting structures
Skill Level Beginner
1. Getting Started
2. Programming Basics
3. Program Flow Control
4. Intermediate C Language Concepts
5. Advanced C Language Concepts
Next steps2m 11s
- 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.Cancel
Take 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.