title: C programming, how would I find the oldest date in an array of date structures?
body: <p>I have a nested structure, the "inside structure" is a date structure with the members; day, month and year. The structures are contained in a dynamic array. I would like to loop through the structures and find which struct has the oldest date. I'm new to programming and not quite sure on how to approach this. Please help. Thanks!</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  //define structure to store students birth date
  struct date
  {
      int month;
      int day;
      int year;
  };
  //define structure to store student info and date structure for birth date
  struct studentInfo
  {
      int iD;
      struct date birthDate;
      int phone;
  };
  
  int main(void)
  {
      //declare and initialize variables
      int recNum = 0;     //number of records
      struct studentInfo * records = NULL;    //struct pointer, array
      //request user input  and store in recNum for record amount
      printf("\nHow many students do you need to enter records for?:");
      scanf ("%d",&amp;recNum);
      //dynamically allocate memory
      records = (struct studentInfo*)malloc((sizeof(struct studentInfo)*recNum));
      //loop through records and request/store values from user
      int count;
      int studentNum=1;
      for(count=0;count&lt;recNum;count++)
      {
          printf("Please enter the following for student number %d\n",studentNum);
          //request and store student ID
          printf("Student ID#:");
          scanf ("%d",&amp;records[count].iD);
          //request and store student phone number
          printf("Student phone# (numbers only, 10 digits):");
          scanf ("%d",&amp;records[count].phone);
  
          //error checking, check if phone number is 10 digits
          int phoneCount = 0;
          int phoneCopy = records[count].phone;
          while(phoneCopy != 0)
          {
              phoneCopy /= 10;
              phoneCount++;
          }
          if (phoneCount != 10)
          {
              printf("The number you have entered is not 10 digits, please re-enter:");
              scanf ("%d",&amp;records[count].phone);
          }
  
          //request and store student birthdate
          printf("Student birthday (mm/dd/yyyy):");
          scanf("%d/%d/%d",&amp;records[count].birthDate.month,&amp;records[count].birthDate.day,
                  &amp;records[count].birthDate.year);
  
          //test stuff
          printf("Student number %d has an ID of %d and a phone number of %d\n", studentNum,
                  records[count].iD, records[count].phone);
          studentNum++;
      }
      return 0;
  }
  </code></pre>