CCL Home Page
Up Directory CCL ordinal
#include "utility.h"

#define MAX_KNOWN_NUMBER 20

char *ordinal(number,ordinal_string)
/*============================================================================*/
/* PURPOSE: TO CONVERT AN INTEGER INTO AN ORDINAL NUMBER STRING.
/* INPUTS:
/*	NUMBER		INTEGER TO CONVERT TO ORDINAL.
/* OUTPUTS:
/*	ORDINAL_STRING	ORDINAL NUMBER REPRESENTATION OF NUMBER.
/*	FUNCTION VALUE	ORDINAL NUMBER REPRESENTATION OF NUMBER.
/* WRITTEN: M.V.GRIESHABER
/* LAST MODIFICATION: 15 JANUARY 1993 MVG
*/
   int number;
   char ordinal_string[];
   {
   static char *ordinal_strings[30]={
      "Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh",
      "Eighth","Nineth","Tenth","Eleventh","Twelveth","Thirteenth","Fourteenth",
      "Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth","Twentieth"};
   
   if (number>MAX_KNOWN_NUMBER)
      {
      /* CRUDE, BETTER THAN NOTHING. */
      sprintf(ordinal_string,"%d",number);
      }
   else strcpy(ordinal_string,ordinal_strings[number]);

   return(ordinal_string);
   }
Modified: Fri Feb 11 17:00:00 1994 GMT
Page accessed 5453 times since Sat Apr 17 21:59:00 1999 GMT