From the course: C: Data Structures, Pointers, and File Systems
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Building a structure - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
Building a structure
- [Instructor] A structure is a container for multiple variable types. The variables can be different data types, the same data types, or mixed and matched in various quantities. These variable types are somehow related, or referenced as a single unit, like a record in a database. The keyword struct defines the structure. It's followed by the structure's name and then the set of braces or curly brackets. Within the braces are lists of variable declarations. These become the members of the structure. To use the structure, you must create a variable of the structure type. Structure members are accessed by using the structure variable name, a dot, and then the member name as defined in the structure. So birthday is a structure variable and month is the name of a member of that structure. The members work like any individual variable in your code. They can be assigned values, sent to a function, used in an equation, and so on. In this code the pixel structure is declared at line five. It…
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.
Contents
-
-
-
Understanding arrays2m 59s
-
Working with arrays3m 5s
-
Modifying arrays3m 11s
-
Passing an array to a function3m 17s
-
Working multi-dimensional arrays3m 2s
-
Building a structure3m 23s
-
Nesting structures2m 56s
-
Creating an array of structures2m 28s
-
Sending a structure to a function3m 36s
-
Understanding a union2m 47s
-
Challenge: Presidents of the U.S.A.1m 38s
-
Solution: Presidents of the U.S.A.2m 52s
-
-
-
-
-
-