Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>isascii() test for ascii character (macro)</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
isascii()                Test for ASCII Character (Macro)

 #include   <ctype.h>

 int        isascii(c);
 int        c;                           Integer to be tested

    isascii() is a macro that tests if 'c' is a member of the 7-bit ASCII
    character set; that is, if:

                        0  <=  c  <= 127

    Returns:    True (nonzero) if the integer satisfies the test
                condition and false (zero) if it does not.

      Notes:    isascii() is a macro.

  -------------------------------- Example ---------------------------------

    The following statements get input from stdin, testing that only
    ASCII characters are stored.

         #include <ctype.h>
         #include <stdio.h>

         int x = 0;
         char buffer[80];
         int ch;

         main()
         {
            while (isascii(ch = getchar()) && ch != '~')
                  buffer[x++] = ch;
            printf("data input from console: %s \n",buffer);
         }

See Also: isalpha() isalnum() iscntrl() isdigit()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson