From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Constructing a structure - C Tutorial
From the course: Complete Guide to C Programming Foundations
Solution: Constructing a structure
(upbeat electronic music) - [Instructor] Here's one solution to the challenge, which requires I set up two structures, a date structure, and then a person structure, and I'll do so now. I've decided to name my two structures date and person, and then you see the members assigned according to the challenge. The names you use for the members can be different, but this is the general way it should look. Now I need to create a person structure variable that I will fill with data. I'm calling the person structure variable me. The next step is to assign the values for myself. Here are the values assigned to the me structure that I've created. You can see that I've used nested notation here for the birthday data. Also, very important, you must use the strcpy() function to copy a string in C. You cannot use the assignment operator. Here I'm using strcpy() and this necessitates the inclusion of a new header file. String.h file includes the definition for the strcpy() function, which is…
Contents
-
-
-
-
-
-
-
-
Understanding arrays2m 48s
-
(Locked)
Working with arrays2m 51s
-
(Locked)
Challenge: Creating an array55s
-
(Locked)
Solution: Creating an array1m 41s
-
(Locked)
Passing an array to a function2m 45s
-
(Locked)
Working with multi-dimensional arrays2m 42s
-
(Locked)
Building a structure3m 31s
-
(Locked)
Nesting structures3m 17s
-
(Locked)
Challenge: Constructing a structure1m 3s
-
(Locked)
Solution: Constructing a structure3m 5s
-
(Locked)
Putting structures into an array2m 37s
-
(Locked)
Working with structures and functions3m 47s
-
(Locked)
Chapter challenge: Manipulating a structure1m 22s
-
(Locked)
Chapter solution: Manipulating a structure2m 4s
-
-
-
-
-
-