Hey guys im writing a function to exstract the user date and then ask user input for there bithday to calculate there age. I have tokenized the current date but how would i put those 3 strings into 3 ints by casting. My casting does not work.. for example user enters 12/12/1984
the strtok tokenizers it into 12 12 1984 as a string. But how would i put them into seperate integers called dayr monthr and yearr? This is an ansi c program!

Code:
void ageCalculator()
{
 char buff[BUFSIZ];
 struct tm t;
 time_t now;
 int m,d,y;
 char input [MAXDATE]; /* buffer size is 12 */
 int valid = 0;
 int date[3]; /* 0 = day 1= month 2=year*/
 
 char *day, *month, *year;
 int dayr, monthr, yearr;
 /* declaration of variables */

 time(&now); 
 /* put now into time */

 t = *localtime(&now); 
 /* get the current date */

 strftime(buff, sizeof(buff), "%d//%m//%y", &t); 
 /* format the date*/
  

 /* --- printing the date ---- */
  printf("The current date is %s\n",buff);

  printf("\nPlease Enter your age in dd/mm/yyyy format:");

   fgets(input, MAXDATE, stdin);

  do
  {

   if ( fgets ( input, sizeof input, stdin ) != NULL ) 
   {
     valid = 0;
       
   }     

    if ( sscanf ( input, "%d/%d/%d", &m, &d, &y ) == 3 )
     {
      if ( is_valid ( m, d, y ) )
      {
        printf ( "\n\n%d/%d/%d is a valid date\n", m, d, y );
        valid = 1;
      }
    }
      else
      {
        printf ("\nInvalid date please enter in dd/mm/yyyy format:");
        valid = 0;
      }
   }
   while(!valid);    
   
   day = strtok(input, "/");
   if (day) printf("%s\n", day); // tokenizing

    month = strtok(NULL, "/"); // casting
    if (month)   printf("%s\n", month);

   year = strtok(NULL, "/");
   if (year) printf("%s\n", year);   
   loopyear();

   // this tokenizers current date and attempts to cast
   dayr = strtok(buff, "/");
   if (dayr) printf("%s\n", dayr);
   dayr = atoi(&t);
   
   monthr = strtok(NULL, "/");
   if (monthr) printf("%s\n", monthr);
   monthr = atoi(&t);

   yearr = strtok(NULL, "/");
   if (yearr) strtok(NULL, "/"); printf("%s\n",yearr);
   yearr = atoi(&t);   
 }


int is_valid ( int m, int d, int y )
{
  static const int  mday[] =
  {
    0,31,28,31,30,31,30,31,31,30,31,30,31
  };

  if ( m <= 0 || m > 12 )
    return 0;
  else if ( d <= 0 || d > mday[m] )
    return 0;
  else if ( y < 1900 || y > 3000 ) /* Arbitrary choices */
    return 0;

  return 1;
}

int loopyear()
{
 int days = 0;
 int leapdays;
 int nonleapdays;
 int year;

 leapdays = year % 4;
 nonleapdays = year % 100;

 days = leapdays - nonleapdays;
 printf("\n%d number of days",days);
 return days;
}