title: Adding "th", "nd" or "rd" to a date in C
body: <p>I'm modifying some driver software for my keyboard and part of it is a plugin that outputs the date to my keyboard screen. At the moment it says 1 January but I really want it to say 1st, 2nd, 3rd or 4th or whatever.</p>
  
  <p>I've been looking everywhere for some kind of code that will give me some kind of an idea on how to do it but I can only find examples for C# and I'm using C.</p>
  
  <p>Edit:</p>
  
  <pre><code>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-&gt;tm_mday], mon);
  </code></pre>