In article <11**********************@g14g2000cwa.googlegroups .com>,
<hu*********@yahoo.com> wrote:
I'm looking for C code that will give me the last day of the month.
Input - any day that I pass in as a variable....
input = 20050201
Output - calculate and format with slashes....
output = 2005/02/28
Here's the easy part:
--------
int ndays[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};
int get_last_day(int month,int year)
{
int ret=ndays[month];
if(is_leap(year) && month==2)
ret++;
return ret;
}
--------
Extracting the month and year from your input, implementing is_leap,
and packing the last day (along with the month and year) into the output
format are left as exercises.
dave
--
Dave Vandervies
dj******@csclub.uwaterloo.ca
What you have in mind about trees is extremely obscure. They come in green,
red-black, avl, binary, B, deciduous, non-deciduous, tropical, fruit,
ornamental, just to name a few varieties. --CBFalconer in comp.lang.c