Now, Somewhere on the Stack Exchange, I heard some crud about you just can't have a struct as a member of a struct. Well, you sure can and now for all the curious minds out there I will show you how to do it. Remember I work with flight simulation, so you always need to know where you are. This is called position, and it is made up of both a Latitude and a Longitude which are both structures of themselves, enclosed in an outer structure.
First I need to create two structs called Lat and Lon and I will make them out of a structure that I call DM, or Degrees and Minutes, and you also need to know the Hemisphere or hemi.
struct DM {
int degrees;
float minutes;
char hemi;
};
struct DM Lat;
struct DM Lon;Now that I have that out of the way, I need to put this together and create my three structures: Current, Start, and Finish. You will note they all have a structure type of Position. So you ask how do I access them? Well, you just use dotted notation.
struct Position{
struct DM Lat;
struct DM Lon; } Current, Start, Finish;
// Carswell: 32-46.151167N 097-26.492083W Start.Lon.degrees = 32; Start.Lon.minutes = 46.151167; Start.Lon.hemi = 'N'; Start.Lat.degrees = 97; Start.Lat.minutes = 26.492083; Start.Lat.hemi = 'W';
Now, I hope I have helped some of you.. I think this will close this blog.