I do not know about any standard library function that does that for you but you can implement something like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int ones_place = n % 10;
int tens_place = ( n / 10 ) % 10;
if (tens_place != 1) {
switch (ones_place) {
case 0:
addSuffix( n, "th" ); // assuming you have a function addSuffix
break;
case 1:
addSuffix( n, "st" );
break;
...
}
} else { // if tens_place == 1
addSuffix( n, "th" );
}