SQL HTML CSS Javascript Python Java C C++ PHP Scala
Arduino - Character Functions
Chat w/ Online
Experts 24/7
A Technician Will Answer Your
Questions in Minutes. Chat Now.
JustAnswer
Open
All data is entered into computers as characters, which includes letters, digits
and various special symbols. In this section, we discuss the capabilities of C++
for examining and manipulating individual characters.
The character-handling library includes several functions that perform useful
tests and manipulations of character data. Each function receives a character,
represented as an int, or EOF as an argument. Characters are often
manipulated as integers.
Remember that EOF normally has the value 1 and that some hardware
architectures do not allow negative values to be stored in char variables.
Therefore, the character-handling functions manipulate characters as integers.
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 1 of 12
:
The following table summarizes the functions of the character-handling library.
When using functions from the character-handling library, include the
<cctype> header.
S.No. Prototype & Description
int isdigit( int c )
1
Returns 1 if c is a digit and 0 otherwise.
int isalpha( int c )
2
Returns 1 if c is a letter and 0 otherwise.
int isalnum( int c )
3
Returns 1 if c is a digit or a letter and 0 otherwise.
int isxdigit( int c )
Returns 1 if c is a hexadecimal digit character and 0 otherwise.
4
(See Appendix D, Number Systems, for a detailed explanation of
binary, octal, decimal and hexadecimal numbers.)
int islower( int c )
5
Returns 1 if c is a lowercase letter and 0 otherwise.
int isupper( int c )
6
Returns 1 if c is an uppercase letter; 0 otherwise.
int isspace( int c )
Returns 1 if c is a white-space characternewline ('\n'), space
7
(' '), form feed ('\f'), carriage return ('\r'), horizontal tab ('\t'), or
vertical tab ('\v')and 0 otherwise.
int iscntrl( int c )
Returns 1 if c is a control character, such as newline ('\n'), form feed
8
('\f'), carriage return ('\r'), horizontal tab ('\t'), vertical tab ('\v'),
alert ('\a'), or backspace ('\b')and 0 otherwise.
int ispunct( int c )
9 Returns 1 if c is a printing character other than a space, a digit, or a
letter and 0 otherwise.
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 2 of 12
:
int isprint( int c )
10 Returns 1 if c is a printing character including space (' ') and 0
otherwise.
int isgraph( int c )
11 Returns 1 if c is a printing character other than space (' ') and 0
otherwise.
Examples
The following example demonstrates the use of the functions isdigit, isalpha,
isalnum and isxdigit. Function isdigit determines whether its argument is a
digit (09). The function isalpha determines whether its argument is an
uppercase letter (A-Z) or a lowercase letter (az). The function isalnum
determines whether its argument is an uppercase, lowercase letter or a digit.
Function isxdigit determines whether its argument is a hexadecimal digit (AF,
af, 09).
Example 1
void setup () {
Serial.begin (9600);
Serial.print ("According to isdigit:\r");
Serial.print (isdigit( '8' ) ? "8 is a": "8 is not a");
Serial.print (" digit\r" );
Serial.print (isdigit( '8' ) ?"# is a": "# is not a") ;
Serial.print (" digit\r");
Serial.print ("\rAccording to isalpha:\r" );
Serial.print (isalpha('A' ) ?"A is a": "A is not a");
Serial.print (" letter\r");
Serial.print (isalpha('A' ) ?"b is a": "b is not a");
Serial.print (" letter\r");
Serial.print (isalpha('A') ?"& is a": "& is not a");
Serial.print (" letter\r");
Serial.print (isalpha( 'A' ) ?"4 is a":"4 is not a");
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 3 of 12
:
Serial.print (" letter\r");
Serial.print ("\rAccording to isalnum:\r");
Serial.print (isalnum( 'A' ) ?"A is a" : "A is not a" );
Serial.print (" digit or a letter\r" );
Serial.print (isalnum( '8' ) ?"8 is a" : "8 is not a" ) ;
Serial.print (" digit or a letter\r");
Serial.print (isalnum( '#' ) ?"# is a" : "# is not a" );
Serial.print (" digit or a letter\r");
Serial.print ("\rAccording to isxdigit:\r");
Serial.print (isxdigit( 'F' ) ?"F is a" : "F is not a" );
Serial.print (" hexadecimal digit\r" );
Serial.print (isxdigit( 'J' ) ?"J is a" : "J is not a" ) ;
Serial.print (" hexadecimal digit\r" );
Serial.print (isxdigit( '7' ) ?"7 is a" : "7 is not a" ) ;
Serial.print (" hexadecimal digit\r" );
Serial.print (isxdigit( '$' ) ? "$ is a" : "$ is not a" );
Serial.print (" hexadecimal digit\r" );
Serial.print (isxdigit( 'f' ) ? f is a" : "f is not a");
void loop () {
Result
According to isdigit:
8 is a digit
# is not a digit
According to isalpha:
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 4 of 12
:
A is a letter
b is a letter
& is not a letter
4 is not a letter
According to isalnum:
A is a digit or a letter
8 is a digit or a letter
# is not a digit or a letter
According to isxdigit:
F is a hexadecimal digit
J is not a hexadecimal digit
7 is a hexadecimal digit
$ is not a hexadecimal digit
f is a hexadecimal digit
We use the conditional operator (?:) with each function to determine whether
the string " is a " or the string " is not a " should be printed in the output for
each character tested. For example, line a indicates that if '8' is a digiti.e., if
isdigit returns a true (nonzero) valuethe string "8 is a " is printed. If '8' is not
a digit (i.e., if isdigit returns 0), the string " 8 is not a " is printed.
Example 2
The following example demonstrates the use of the functions islower and
isupper. The function islower determines whether its argument is a lowercase
letter (az). Function isupper determines whether its argument is an uppercase
letter (AZ).
int thisChar = 0xA0;
void setup () {
Serial.begin (9600);
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 5 of 12
:
Serial.print ("According to islower:\r") ;
Serial.print (islower( 'p' ) ? "p is a" : "p is not a" );
Serial.print ( " lowercase letter\r" );
Serial.print ( islower( 'P') ? "P is a" : "P is not a") ;
Serial.print ("lowercase letter\r");
Serial.print (islower( '5' ) ? "5 is a" : "5 is not a" );
Serial.print ( " lowercase letter\r" );
Serial.print ( islower( '!' )? "! is a" : "! is not a") ;
Serial.print ("lowercase letter\r");
Serial.print ("\rAccording to isupper:\r") ;
Serial.print (isupper ( 'D' ) ? "D is a" : "D is not an" );
Serial.print ( " uppercase letter\r" );
Serial.print ( isupper ( 'd' )? "d is a" : "d is not an") ;
Serial.print ( " uppercase letter\r" );
Serial.print (isupper ( '8' ) ? "8 is a" : "8 is not an" );
Serial.print ( " uppercase letter\r" );
Serial.print ( islower( '$' )? "$ is a" : "$ is not an") ;
Serial.print ("uppercase letter\r ");
}
void setup () {
Result
According to islower:
p is a lowercase letter
P is not a lowercase letter
5 is not a lowercase letter
! is not a lowercase letter
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 6 of 12
:
According to isupper:
D is an uppercase letter
d is not an uppercase letter
8 is not an uppercase letter
$ is not an uppercase letter
Example 3
The following example demonstrates the use of functions isspace, iscntrl,
ispunct, isprint and isgraph.
The function isspace determines whether its argument is a white-space
character, such as space (' '), form feed ('\f'), newline ('\n'), carriage
return ('\r'), horizontal tab ('\t') or vertical tab ('\v').
The function iscntrl determines whether its argument is a control
character such as horizontal tab ('\t'), vertical tab ('\v'), form feed
('\f'), alert ('\a'), backspace ('\b'), carriage return ('\r') or newline
('\n').
The function ispunct determines whether its argument is a printing
character other than a space, digit or letter, such as $, #, (, ), [, ], {, },
;, : or %.
The function isprint determines whether its argument is a character
that can be displayed on the screen (including the space character).
The function isgraph tests for the same characters as isprint, but the
space character is not included.
void setup () {
Serial.begin (9600);
Serial.print ( " According to isspace:\rNewline ") ;
Serial.print (isspace( '\n' )? " is a" : " is not a" );
Serial.print ( " whitespace character\rHorizontal tab") ;
Serial.print (isspace( '\t' )? " is a" : " is not a" );
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 7 of 12
:
Serial.print ( " whitespace character\n") ;
Serial.print (isspace('%')? " % is a" : " % is not a" );
Serial.print ( " \rAccording to iscntrl:\rNewline") ;
Serial.print ( iscntrl( '\n' )?"is a" : " is not a" ) ;
Serial.print (" control character\r");
Serial.print (iscntrl( '$' ) ? " $ is a" : " $ is not a" );
Serial.print (" control character\r");
Serial.print ("\rAccording to ispunct:\r");
Serial.print (ispunct(';' ) ?"; is a" : "; is not a" ) ;
Serial.print (" punctuation character\r");
Serial.print (ispunct('Y' ) ?"Y is a" : "Y is not a" ) ;
Serial.print ("punctuation character\r");
Serial.print (ispunct('#' ) ?"# is a" : "# is not a" ) ;
Serial.print ("punctuation character\r");
Serial.print ( "\r According to isprint:\r");
Serial.print (isprint('$' ) ?"$ is a" : "$ is not a" );
Serial.print (" printing character\rAlert ");
Serial.print (isprint('\a' ) ?" is a" : " is not a" );
Serial.print (" printing character\rSpace ");
Serial.print (isprint(' ' ) ?" is a" : " is not a" );
Serial.print (" printing character\r");
Serial.print ("\r According to isgraph:\r");
Serial.print (isgraph ('Q' ) ?"Q is a" : "Q is not a" );
Serial.print ("printing character other than a space\rSpace
");
Serial.print (isgraph (' ') ?" is a" : " is not a" );
Serial.print ("printing character other than a space ");
}
void loop () {
Home Whiteboard Online Compilers Practice Articles Jobs
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 8 of 12
:
} Chapters Categories
Result
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
Space is 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
TOP TUTORIALS
Python Tutorial
Java Tutorial
C++ Tutorial
C Programming Tutorial
C# Tutorial
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 9 of 12
:
PHP Tutorial
R Tutorial
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
SQL Tutorial
TRENDING TECHNOLOGIES
Cloud Computing Tutorial
Amazon Web Services Tutorial
Microsoft Azure Tutorial
Git Tutorial
Ethical Hacking Tutorial
Docker Tutorial
Kubernetes Tutorial
DSA Tutorial
Spring Boot Tutorial
SDLC Tutorial
Unix Tutorial
CERTIFICATIONS
Business Analytics Certification
Java & Spring Boot Advanced Certification
Data Science Advanced Certification
Cloud Computing And DevOps
Advanced Certification In Business Analytics
Artificial Intelligence And Machine Learning
DevOps Certification
Game Development Certification
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 10 of 12
:
Front-End Developer Certification
AWS Certification Training
Python Programming Certification
COMPILERS & EDITORS
Online Java Compiler
Online Python Compiler
Online Go Compiler
Online C Compiler
Online C++ Compiler
Online C# Compiler
Online PHP Compiler
Online MATLAB Compiler
Online Bash Terminal
Online SQL Compiler
Online Html Editor
ABOUT US | OUR TEAM | CAREERS | JOBS | CONTACT US |
TERMS OF USE | PRIVACY POLICY | REFUND POLICY | COOKIES POLICY | FAQ'S
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 11 of 12
:
Tutorials Point is a leading Ed Tech company striving to provide the best learning
material on technical and non-technical subjects.
© Copyright 2025. All Rights Reserved.
https://www.tutorialspoint.com/arduino/arduino_character_functions.htm 8/21/25, 08 50
Page 12 of 12
: