#include <ctype.h> int isspace(int c);
isspace
tests an integer value c
to determine whether it is
white space; that is, a blank, tab, new line, carriage return, form
feed, or vertical tab character. In the 5370 and POSIX locales,
isspace
returns true only for standard white-space characters.
isspace
returns 0 if the character is not white space, or a nonzero
value if it is. If the argument is EOF
, 0 is returned.
isspace
on a noncharacter argument other than EOF
is undefined. Do not assume that isspace
returns either 0 or 1.
#include <ctype.h> #include <stdio.h> #include <stdlib.h> main() { int c, n; puts("Enter a character when prompted.. even spaces are OK."); for (n = 1;; n++ ) { puts("Enter now (q to quit): "); c = getchar(); if (c == 'q') exit(0); printf("The character you entered %s a space charactern", isspace(c) ? "is" : "is not"); if (c != 'n') getchar(); /* Read the new line. */ } }
iscntrl
, isgraph
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.