.c code: ascii.c

This program prints an abbreviated ascii chart.

// ascii.c - dump the ascii chart
#include 

showChart(FILE *out) {
  int onech = 0;
  char imgch[8];

  imgch[0] = 0;

  while (onech < 128) {
    if (onech < ' ') {
      sprintf(imgch, "^%c ", onech + '@');
    } else {
      sprintf(imgch, " %c ", onech);
    }

    fprintf(out, "%3d %3s ", onech, imgch);
    if (onech % 8 == 7) {
      fprintf(out, "\n");
    }
      
    ++onech;
  }
  

}

int main(int agcnt, char **argval, char **envval) {
  showChart(stdout);
}
Scroll to Top