我正在为我的键盘修改一些驱动程序软件,其中一部分是一个将日期输出到我的键盘屏幕的插件。目前它说的是 1 月 1 日,但我真的希望它说 1 日、2 日、3 日或 4 日或其他什么。
我一直在到处寻找某种代码,这些代码会给我一些关于如何做到这一点的想法,但我只能找到 C# 的示例,而且我正在使用 C。
编辑:
const char *ordinals[] = {"", "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th", "31st"};
sprintf(date, "%s %s", ordinals[t->tm_mday], mon);