title: C - How to Obtain a Time in C Using a Struct
body: <p>I have an issue in my C project which involves an assortment of schedules, and each schedule needs a date. I obtain it using a struct.  Now I would like to delete all the old schedules, so in order to do this the code nees to:</p>
  
  <ul>
  <li>Get the present time</li>
  <li>Run my list to compare whether (Date(now) > Date(old)).  If true, the code will delete the pertinent schedule.</li>
  </ul>
  
  <p>The primary issue concerns how to get the real time, and pass it to my struct.  Can anyone help in this regard?</p>
  
  <p>The code that attempts to get the real time and put into a struct is as follows:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  
  typedef struct date Date;
  typedef struct hour Hour;
  
  struct hour{
  
      int hour;
      int minute;
      int second;
  
  };
  
  struct date{
  
      int day;
      int month;
      int year;
      Hour hour;
  
  };
  
  int main (void) {
  
      Date date;
  
      //char buff[100];
      time_t now = time(0);    
      strftime (date, 100, "%d-%m-%Y %H:%M:%S", localtime(&amp;now));
      printf ("%s\n", date);
  
      //I want to put localtime(&amp;now) on date instead buff that is a char!
      //To me compare after
  
      return 0;
  
  }
  </code></pre>