Q:

Design a structure to store time and date. Write a function to find the difference between two times in minutes

I'm completing an O'Reilly textbook on my own and I'm now at structures. One of the programming exercises is:
Design a structure to store time and date. Write a function to find the difference between two times in minutes.
I believe I have the structure part down, I'm confused about the difference function though. I'm being very lazy by not taking into consideration the amount of days apart, but the question asks for time apart so I'm going to pretend as if it's just a 24 hour day they are talking about. Can I call a structure in the parameters of a function? I certainly tried to. Any suggestions would help. Thanks
My code thus far(in no way completed):
#include <iostream>

int difference(struct date_time);

int main()
{
    return 0;
}

struct date_time{
    int day;
    char month[20];
    int year;
    int second;
    int minute;
    int hour;
} super_date_time = {
    29,
    "may",
    2013,
    30,
    30,
    23
    };
int difference(date_time)
{
    int second1 = 45;
    int minute1 = 50;
    int hour1 = 24;

    std::cout << "Time difference is " << hour1 - int hour
    return 0;
}

A:

Sticking with your data structure ...
// Passing your structures by reference (&)
double MA_TimeDiffMinutes(const struct date_time& t1, const struct date_time& t2) {
  // As per your instruction, ignore year, month, day
  int diff = ((t1.hour - t2.hour)*60 + t1.minute - t2.minute)*60 + t1.second - t2.second;
  return diff/60.0;
}

int main() {
  struct date_time t_first;
  struct date_time t_next;
  // TBD fill the fields of t_first and t_next.
  cout << MA_TimeDiffMinutes(t_next, t_first) << endl;
}

Consider using an integer representation of month rather than a string.

