#include <stdio.h>
#include <string.h>
int main()
{
char date1[11]="12-11-2013",date2[11]="12-11-1995";
int i=0,day1=0,day2=0,month1=0,month2=0,year1=0,year2=0;
while(i<10)
{
if(i==2 || i==5)
{
i++;
}
else if(i<2)
{
day1 = day1 * 10 + ( date1[i] - '0' );
day2 = day2 * 10 + ( date2[i] - '0' );
i++;
}
else if(i>2 && i<5)
{
month1 = month1 * 10 + ( date1[i] - '0' );
month2 = month2 * 10 + ( date2[i] - '0' );
i++;
}
else
{
year1 = year1 * 10 + ( date1[i] - '0' );
year2 = year2 * 10 + ( date2[i] - '0' );
i++;
}
}
printf("%d", year1);
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.