Recently I was assigned a program for class and I've been having some problems. At my old school, the teacher worded the instructions differently, so I am not entirely sure how to translate the following lines of instruction into the proper setup for my structs, arrays, and shorts.

Instructions:
1. Typedef struct Day contains a short named "day", a short named "month", an array named "appts" of eight pointers to typedef struct Appointment, and a short named "apptCount".
2. Typedef struct Appointment contains: "startTime" and "endTime" of typedef struct Time, a dynamically allocated array of char named "subject", and a dynamically allocated array of char named "location".
3. Typedef struct Time uses contains a short named "hour" (0 – 23), a short named "minute".

I have come up with the following, but I feel like I'm doing it wrong as it seems like the structs are more intertwined than this:

typedef struct Appointment
{
  char subject[], location[];
  int appts[8];
}; // End struct Appointment

typedef struct Day
{
  short day, month, apptCount;
  int days[];
}; //End struct Day

typedef struct Time
{
  string startTime, endTime;
  short hour, minute;
}; //End struct Time

Any direction is greatly appreciated.

typedef struct Time
      {
      string startTime, endTime;
      short hour, minute;
      }; //End struct Time

      typedef struct Appointment
      {
      char* subject;//dynamic menber
      char* location;
     Time startTime, endTime;
      int appts[8];

      }; // End struct Appointment
 
  typedef struct Day
      {
      short day, month, apptCount;
      int days[];
      }; //End struct Day

I think its something like that

Now would I still need the following line in the typedef struct Time:

string startTime, endTime;

Thank for the help. I'm going to run with that and see what I can come up with today.

Let me know if it worked...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.