compare function for dates

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-03-17T22:45:55Z Indexed on 2010/03/17 22:51 UTC
Read the original article Hit count: 236

Filed under:
|
|

I have struct as:

struct stored
{
    char *dates; // 12/May/2010, 10/Jun/2010 etc..
    int ctr;
};
// const
struct stored structs[] = {{"12/May/2010", 1}, {"12/May/2011", 1}, 
                           {"21/May/2009", 4}, {"12/May/2011", 3}, 
                           {"10/May/2011", 8}, {"12/May/2011", 4 }};

What I want to do is to sort struct 'stored' by stored.dates.

qsort(structs, 9, sizeof(struct stored*), sortdates); // sortdates function

I'm not quite sure what would be a good way to sort those days? Compare them as c-strings?

© Stack Overflow or respective owner

Related posts about c

    Related posts about date