Join Dan Gookin for an in-depth discussion in this video Structures with structures, part of Up and Running with C.
- View Offline
- Exercise Files
- When your program needs memory…you can allocate it on the fly.…That includes memory for any variable type array…or even a structure.…In this movie, I demonstrate how structures…can be created using pointers…with their memory allocated as the program runs.…In this code, storage for a structure is allocated.…The structure has to be defined first,…which happens at line six.…Remember, that a structure itself, isn't a variable.…It's simply a declaration of what…the contents of a structure would be.…
In this case, the members are month, day, year.…At line 11, a pointer variable…for that kind of structure is created.…The pointer is a memory location.…It's not the structure.…Storage for the structure is allocated at line 13,…courtesy of the malloc function.…See how the "sizeof" operator is used…to allocate enough storage for the structure itself.…
And the structure's name is used,…not the structure pointer variable.…Assuming that the structure is created,…lines 20 through 25 fill the structure.…Because the structure is referenced by a pointer,…
- 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.