Thu Nov 13, 2008 2:21 pm
/*
* This program prints out a table of the ascii character values.
*/
#include <stdio.h>
#include <ctype.h>
int main()
{
int code; /* Ascii value. */
for(code = 0; code < 128; ++code) {
/* Print the code and the character itself. */
printf("%3d ", code);
if(isspace(code))
printf(" ");
else if(isprint(code))
printf("%c", code);
else
printf(" ");
/* If any of the interesting categories match, print it. */
if(code == '\n')
printf(" (newline, \\n)\n");
else if(code == ' ')
printf(" (space)\n");
else if(code == '\t')
printf(" (tab, \\t)\n");
else if(isspace(code))
printf(" (blank character)\n");
else if(iscntrl(code))
printf(" (control character)\n");
else if(isupper(code))
printf(" (capitol of %c)\n", tolower(code));
else if(islower(code))
printf(" (lower case of %c)\n", toupper(code));
else if(isdigit(code))
printf(" (digit)\n", toupper(code));
else
putchar('\n');
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.