【发布时间】:2010-03-17 22:45:55
【问题描述】:
我的结构为:
struct stored
{
char *dates; // 12/May/2010, 10/Jun/2010 etc..
};
// const
struct stored structs[] = {{"12/May/2010"}, {"12/May/2011"},
{"21/May/2009"}, {"13/May/2011"},
{"10/May/2011"}, {"19/May/2011"}};
我想要做的是按stored.dates 对struct 'stored' 进行排序。
qsort(structs, 9, sizeof(struct stored*), sortdates); // sortdates function
我不太确定这些日子有什么好办法?将它们作为 c 字符串进行比较?
【问题讨论】:
-
日期的格式——日(dd)、月(MMM)、年(yyyy)——总是一样的吗?
-
ctr 基本上只是一个计数器 - 不需要
-
格式总是一样的