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

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