Advertisement
ntrrgc

The ascii ordering, by Windows

Jul 10th, 2012
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <windows.h>
  2. #include <ctype.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. int compar(const void* a, const void* b) {
  7.     char a_[2] = " ";
  8.     char b_[2] = " ";
  9.     a_[0] = ((const char*)a)[0];
  10.     b_[0] = ((const char*)b)[0];
  11.     return lstrcmp(a_, b_);
  12. }
  13.  
  14. int main(int argc, const char *argv[])
  15. {
  16.     char ascii[128];
  17.     int i;
  18.     for (i = 0; i < sizeof(ascii); i++)
  19.         ascii[i] = i;
  20.  
  21.     qsort(ascii, sizeof(ascii), 1, &compar);
  22.  
  23.     printf("%s", "The ascii characters are matched in the following order:\n");
  24.     for (i = 0; i < sizeof(ascii); i++) {
  25.         printf("Code %3d", ascii[i]);
  26.         if (isgraph(ascii[i]))
  27.             printf(" %c", ascii[i]);
  28.         printf("\n");
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement