| Muggy (7) | |||
|
Hi everyone, I am having trouble working with structs. The objective of the assignment is: In Chapter 9, you were asked to write a program that keeps track of important birthdays. Modify this program to store one person’s birthday information in a struct data type. The struct should consist of two other structs: one struct to hold the person’s first name and last name, and another to hold the date (day, month, and year). Here is my code so far (messy) and I used the structure tutorial on this site:
| |||
|
Last edited on
|
|||
| Code Assassin (295) | |
|
You really don't state your problem. All your saying is your having problem with structs - then you post your assignment. No ones going to do your code for you but I'll refer you to this thread: http://www.dreamincode.net/forums/topic/146508-struct-within-a-struct/ | |
|
|
|
| Muggy (7) | |
|
I got it to work; I didn't realize structs within a struct didn't translate to calling out multiple structs within the struct (mind-boggling). Here's what I did for anyone interested: *deleted, bad code* | |
|
Last edited on
|
|
| maeriden (244) | |
| Isn't you assignemnt telling you to use two structs inside a main struct to hold the info? Or you don't care for that? | |
|
Last edited on
|
|
| Muggy (7) | |
| Hm, yeah you're right. Do you think you can give me an example how I can do that? I've tried looking everywhere but I can't seem to find use of structs within a struct. My program is also not turning up parts of information.. think I effed up something somewhere. Currently doing a rehaul of everything. | |
|
|
|
| maeriden (244) | |||||
It's as simple as
Note that you can also define the substruct outside the main struct. In this case only the second method of variable declaration can be used
| |||||
|
Last edited on
|
|||||
| Code Assassin (295) | |
| Just like maeriden posted. Did you look at my link? It gave you an example. | |
|
|
|