Skip to content

Instantly share code, notes, and snippets.

@foysalit
Created June 12, 2013 12:40
Show Gist options
  • Save foysalit/5764897 to your computer and use it in GitHub Desktop.
Save foysalit/5764897 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char date[10] = "10/02/2012";
char day[10];
char month[10];
char year[10];
int max = 0;
strncpy(year, date+6, 4);
year[4] = '\0';
strncpy(month, date+3, 2);
month[2] = '\0';
strncpy(day, date, 2);
day[2] = '\0';
if(atoi(year) > max){
max = atoi(year);
}
printf("%d", max);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment