Here is a C version of the script, this was written by Steve Frostrom [the Original author of the Bash version].
#include#include #define FMTH "%5s %9s %11s %11s %9s %9s\n" #define FMT "%5s %9d %11d %11.1f %9s %9s\n" char *say(char *str, int val) { char ends; if (! val) return(strcpy(str, "--")); sprintf(str, "%d", val); switch (val) { case 11: case 12: case 13: return(strcat(str, "th")); default: ends = str[strlen(str) - 1]; switch (ends) { case '0': case '4': case '5': case '6': case '7': case '8': case '9': return(strcat(str, "th")); case '1': return(strcat(str, "st")); case '2': return(strcat(str, "nd")); case '3': return(strcat(str, "rd")); } } } main(int argc, char *argv[]) { int MAXLEVEL = (argc > 1) ? atoi(argv[1]) : 40; int level, xp, maxranks, feats, stats, say_feats, say_stats; float maxcc; static char str_level[5], str_feats[5], str_stats[5]; system("clear"); printf(FMTH, "Char", "", "Class Skill", "CC Skill", "", "Stat"); printf(FMTH, "Level", "XP", "Max Ranks", "Max Ranks", "Feats", "Inc's"); for (level = 1, xp = 0, feats = 1, stats = 0 ; level <= MAXLEVEL; level++) { xp += (level - 1) * 1000; maxranks = level + 3; maxcc = maxranks / 2.0; say_feats = (level % 3) ? (level == 1 ? 1 : 0) : ++feats; say_stats = (level % 4) ? 0 : ++stats; printf(FMT, say(str_level, level), xp, maxranks, maxcc, say(str_feats, say_feats), say(str_stats, say_stats)); } }