Using functions isspace, iscntrl, ispunct, isprint, isgraph : char function « Data Type « C Tutorial

Home
C Tutorial
1.Language
2.Data Type
3.String
4.printf scanf
5.Operator
6.Statement
7.Array
8.Function
9.Structure
10.Pointer
11.Memory
12.Preprocessor
13.File
14.Data Structure
15.Search Sort
16.Wide Character String
17.assert.h
18.ctype.h
19.math.h
20.setjmp.h
21.signal.h
22.stdio.h
23.stdlib.h
24.string.h
25.time.h
26.wctype.h
C / ANSI-C
C++
C++ Tutorial
Visual C++ .NET
C Tutorial » Data Type » char function 
2.15.3.Using functions isspace, iscntrl, ispunct, isprint, isgraph
#include <stdio.h>
#include <ctype.h>

int main()
{
   printf"%s\n%s%s%s\n%s%s%s\n%s%s\n\n"
       "According to isspace:"
       "Newline", isspace'\n' " is a " " is not a ",
       "whitespace character""Horizontal tab",
       isspace'\t' " is a " " is not a "
       "whitespace character",
       isspace'%' "% is a " "% is not a ",
       "whitespace character" );

   printf"%s\n%s%s%s\n%s%s\n\n""According to iscntrl:"
       "Newline", iscntrl'\n' " is a " " is not a ",
       "control character", iscntrl'$' "$ is a " 
       "$ is not a ""control character" );

   printf"%s\n%s%s\n%s%s\n%s%s\n\n"
       "According to ispunct:",
       ispunct';' "; is a " "; is not a "
       "punctuation character",
       ispunct'Y' "Y is a " "Y is not a ",
       "punctuation character",
       ispunct'#' "# is a " "# is not a ",
       "punctuation character" );

   printf"%s\n%s%s\n%s%s%s\n\n""According to isprint:",
       isprint'$' "$ is a " "$ is not a "
       "printing character"
       "Alert", isprint'\a' " is a " " is not a ",
       "printing character" );

   printf"%s\n%s%s\n%s%s%s\n",  "According to isgraph:",
       isgraph'Q' "Q is a " "Q is not a ",
       "printing character other than a space",
       "Space", isgraph' ' " is a " " is not a ",
       "printing character other than a space" );

   return 0

}
According to isspace:
Newline is a whitespace character
Horizontal tab is a whitespace character
% is not a whitespace character

According to iscntrl:
Newline is a control character
$ is not a control character

According to ispunct:
; is a punctuation character
Y is not a punctuation character
# is a punctuation character

According to isprint:
$ is a printing character
Alert is not a printing character

According to isgraph:
Q is a printing character other than a space
Space is not a printing character other than a space
2.15.char function
2.15.1.Using functions islower, isupper, tolower, toupper
2.15.2.Using functions isdigit, isalpha, isalnum, and isxdigit
2.15.3.Using functions isspace, iscntrl, ispunct, isprint, isgraph
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.