Ctype.H Results Generation

// done by zephinzer // goto: http://zephinzer.tumblr.com for more // please leave this intact if you use this code // thank you #include <stdio.h> #include <ctype.h> // this defines the upper limit of where the program will stop #define ASCII_RANGE 255 // this defines the upper limit of where the program will stop #define ROW_LENGTH 25 int wontscrewup(char input); int main(void) { printf("\nctype.c by zephinzer\n"); printf("^^^^^^^^^^^^^^^^^^^^\n"); char buffer[ASCII_RANGE]; int counter, master; for(counter=0; counter<ASCII_RANGE; counter++) buffer[counter] = counter; for(master=0; master<ASCII_RANGE; master+=25) { printf(" "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", counter/100); printf("\n"); printf(" "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", (counter/10)%10); printf("\n"); printf(" "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", counter%10); printf("\n"); printf("------------------------------------------------------------"); printf("\ncharacter: "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%c ", wontscrewup(buffer[counter]) ? buffer[counter] : ' '); printf("\n------------------------------------------------------------"); printf("\nisalnum(): "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", isalnum(buffer[counter]) ? 1 : 0); printf("\nisalpha(): "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", isalpha(buffer[counter]) ? 1 : 0); printf("\niscntrl(): "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", iscntrl(buffer[counter]) ? 1 : 0); printf("\nisdigit(): "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", isdigit(buffer[counter]) ? 1 : 0); printf("\nisgraph(): "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", isgraph(buffer[counter]) ? 1 : 0); printf("\nislower(): "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", islower(buffer[counter]) ? 1 : 0); printf("\nisprint(): "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", isprint(buffer[counter]) ? 1 : 0); printf("\nispunct(): "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", ispunct(buffer[counter]) ? 1 : 0); printf("\nisspace(): "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", isspace(buffer[counter]) ? 1 : 0); printf("\nisupper(): "); for(counter=master; counter<master+ROW_LENGTH; counter++) printf("%d ", isupper(buffer[counter]) ? 1 : 0); printf("\n\n"); } return 0; } int wontscrewup(char input) { switch(input) { // 7 causes a beep // 9 is a tab // 10 is a line feed // 13 causes the first part of the line to dissapear case 7: case 9: case 10: case 13: return 0; default: return 1; } }
This shows all values from 0 to the number stipulated in the #define at the top of the code. It also shows which characters will be marked with which properties.

~ zephinzer
- http://zephinzer.tumblr.com

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.