Advertisement
dmilicev

ascii table by columns v1.c

Oct 18th, 2019
214
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.57 KB | None
  1. /*
  2.     ascii table by columns v1.c
  3.  
  4.     Prints ASCII characters in columns.
  5.  
  6.     ASCSII is American Standard Code for Information Interchange
  7.  
  8.     http://www.asciitable.com/
  9.  
  10.     https://theasciicode.com.ar/
  11.  
  12.  
  13.     You can find all my C programs at Dragan Milicev's pastebin:
  14.  
  15.     https://pastebin.com/u/dmilicev
  16.  
  17. */
  18.  
  19. #include <stdio.h>
  20.  
  21. // function to print ascii table by columns
  22. void ascii_table_by_columns(void)
  23. {
  24.     int row, column, c=0, number_of_columns=8, number_of_rows, buffer;
  25.  
  26.     printf("\n\n\t\t   ASCII table by columns \n\n\n\n");
  27.  
  28.     // we calculate the number of rows based on the number of columns
  29.     number_of_rows = (255 / number_of_columns) + 1;
  30.  
  31.     for(row = 0; row < number_of_rows; row++)  // we print rows one by one
  32.     {
  33.         c = row;
  34.  
  35.         for(column = 1; column <= number_of_columns; column++)  // we print columns
  36.         {
  37.              buffer = c;    // we remember c in the buffer
  38.  
  39.             // Instead of characters that cannot be displayed (ascii 7, 8, 10, 13),
  40.             if(c == 7 || c == 8 || c == 10 || c == 13 )
  41.             {
  42.                 c=32;                                   // we print a blank space
  43.             }
  44.  
  45.              if(c <= 255)                               // print character c till 255
  46.              {
  47.                   printf("%6d%2c", buffer, (char)c);
  48.                   c = buffer;                           // return c from buffer
  49.                   c = c + number_of_rows;               // calculating c in next column
  50.              }
  51.         }
  52.  
  53.         printf("\n\n");
  54.     }
  55. }
  56.  
  57.  
  58. int main(void)
  59. {
  60.  
  61.     ascii_table_by_columns();
  62.  
  63.  
  64.     printf("\n\n");
  65.  
  66.     //system("PAUSE");
  67.     getch();
  68.  
  69.     return 0;
  70. }
Advertisement
RAW Paste Data Copied
Advertisement