Created
June 12, 2013 12:40
-
-
Save foysalit/5764897 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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