16

Boolean functions

  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. void pctype( int c ) {
  5.     printf( "%3d(%02X)\t'%c' is a ", c, c, c );
  6.     if ( isdigit( c ) )
  7.         printf("digit");
  8.     else if ( islower( c ) )
  9.         printf("small letter");
  10.     else if ( isupper( c ) )
  11.         printf("capital letter");
  12.     else if ( isspace( c ) )
  13.         printf("space");
  14.     else if ( iscntrl( c ) )
  15.         printf("control");
  16.     else if ( ispunct( c ) )
  17.         printf("punctuation");
  18.     else
  19.         printf("mistery");
  20.     printf(".\n");
  21. }
  22.  
  23. main() {
  24.     int c;
  25.  
  26.     for ( c = 0; c < 128; ++c )
  27.         pctype(c);
  28. }

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].