A subset of ASCII can be printed. Some of these are control characters such as string, call, etc.
Details: ASCII is defined for codes from 0 to 127. For a full ASCII scheme, only for(i=0;i<=127;i++) is required for(i=0;i<=127;i++) .
-
OTOH , maybe you want to print a full graph of all char . When char prints, they are first converted to unsigned char . So, let's create a diagram of all unsigned char .
Note. Using ASCII for character codes from 0 to 127 in a very general way, but not specified C.
To determine if unsigned char can be printed, use the isprint() function. For others, type the escape sequence.
#include<ctype.h> #include<limits.h> #include<stdio.h> int main(void) { unsigned char i = 0; do { printf("%4d: ", i); if (isprint(i)) { printf("'%c'\n", i); } else { printf("'\\x%02X'\n", i); } } while (i++ < UCHAR_MAX); return 0; }
Output example
0: '\x00' 1: '\x01' ... 7: '\x07' 8: '\x08' 9: '\x09' 10: '\x0A' ... 31: '\x1F' 32: ' ' 33: '!' 34: '"' ... 65: 'A' 66: 'B' 67: 'C' ... 126: '~' 127: '\x7F' ... 255: '\xFF'
source share