C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
IS.C
                                             Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
/* IS.C illustrates character classification functions including:
 *      isprint         __isascii       isalpha         isalnum
 *      isupper         islower         isdigit         isxdigit
 *      ispunct         isspace         iscntrl         isgraph
 *
 * Console output is also shown using:
 *      _cprintf
 *
 * See PRINTF.C for additional examples of formatting for _cprintf.
 */
 
#include <ctype.h>
#include <conio.h>
 
void main()
{
    int ch;
 
    /* Display each ASCII character with character type in a table. */
    for( ch = 0; ch < 256; ch++ )
    {
        if( ch % 22 == 0 )
        {
            if( ch )
                _getch();
 
            /* Note that _cprintf does not convert "\n" to a CR/LF sequence.
             * You can specify this sequence with "\n\r".
             */
            _cprintf( "\n\rNum Char ASCII Alpha AlNum Cap Low Digit " );
            _cprintf( "XDigit Punct White CTRL Print Graph \n\r" );
        }
        _cprintf( "%3d  ", ch );
 
        /* Console output functions (_cprintf, _cputs, and _putch) display
         * graphic characters for all values except 7 (bell), 8 (backspace),
         * 10 (line feed), 13 (carriage return), and 255. Characters 9 (tab)
         * and 27 (escape) may display differently in different operating
         * systems.
         */
        if( ch == 7 || ch == 8 || ch == 9 || ch == 10 ||
            ch == 13 || ch == 27 || ch == 255 )
            _cprintf("NV" );
        else
            _cprintf("%c ", ch );
        _cprintf( "%5s", __isascii( ch )  ? "Y" : "N" );
        _cprintf( "%6s", isalpha( ch )  ? "Y" : "N" );
        _cprintf( "%6s", isalnum( ch )  ? "Y" : "N" );
        _cprintf( "%5s", isupper( ch )  ? "Y" : "N" );
        _cprintf( "%4s", islower( ch )  ? "Y" : "N" );
        _cprintf( "%5s", isdigit( ch )  ? "Y" : "N" );
        _cprintf( "%7s", isxdigit( ch ) ? "Y" : "N" );
        _cprintf( "%6s", ispunct( ch )  ? "Y" : "N" );
        _cprintf( "%6s", isspace( ch )  ? "Y" : "N" );
        _cprintf( "%5s", iscntrl( ch )  ? "Y" : "N" );
        _cprintf( "%6s", isprint( ch )  ? "Y" : "N" );
        _cprintf( "%6s\n\r", isgraph( ch )  ? "Y" : "N" );
    }
}
                                    -♦-