isprint


Identification of display character

[Classification]

Standard library

[Syntax]

#include <ctype.h>

int isprint(int c);

[Return value]

These macros return a value other than 0 if the value of argument c matches the respective description (i.e., if the result is true). If the result is false, 0 is returned.

[Description]

This function is a macro that checks whether a given character is a display character (0x20 to 0x7E). This macro is defined only when c is made true by isascii or when c is EOF. A compiled subroutine can be used instead of the macro definition, which is invalidated by using "#undef isprint".

[Example]

#include    <ctype.h>
void func(void) {
        int     i, j = 0;
        char    s[50];
                for (i =50; i <= 99; i++) {
                        if (isprint(i)) {   /*Store the printable characters in the 
                                              code range 50 to 99, in the array s.*/
                        s[j] = i; 
                        j++;
                        }
                }
        :
}