0% found this document useful (0 votes)
19 views

10 - Character Handling Library

The document describes commonly used character handling functions in the ctype.h library. It lists the function prototypes and provides a brief description of what each function does. Sample code is also provided to demonstrate the use of these functions.

Uploaded by

kneel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

10 - Character Handling Library

The document describes commonly used character handling functions in the ctype.h library. It lists the function prototypes and provides a brief description of what each function does. Sample code is also provided to demonstrate the use of these functions.

Uploaded by

kneel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CHARACTER HANDLING LIBRARY (ctype.

h)

The following are the commonly used character handling functions. To use these functions, include
ctype.h library in your program.

Prototype Function Description


int isdigit (int c) Returns a true value if c is a digit and 0 (false) otherwise.
int isalpha (int c) Returns a true value if c is a letter and 0 otherwise.
int isalnum (int c) Returns a true value if c is a digit or a letter and 0 otherwise.
int isxdigit (int c) Returns a true value if c is a hexadecimal digit character and 0 otherwise.
int islower (int c) Returns a true value if c is a lowercase letter and 0 otherwise.
int isupper (int c) Returns a true value if c is an uppercase letter and 0 otherwise.
int tolower (int c) If c is an uppercase letter, tolower returns c as a lowercase letter. Otherwise,
tolower returns the argument unchanged.
int toupper (int c) If c is an uppercase letter, toupper returns c as an uppercase letter. Otherwise,
toupper returns the argument unchanged.
int isspace (int c) Returns a true value if c is a whitespace character – newline (‘\n’), space (‘ ’),
form feed (‘\f’), carriage return (‘\r’), horizontal tab (‘\t’), or vertical tab (‘\v’) –
and 0 otherwise.
int ispunct (int c) Returns a true value if c is a printing character other than a space, a digit, or a
letter and 0 otherwise.

Sample
Sample Program
Output
Exercise

1. Write a program in C to count the total number of words in a string.

Test Data :
Input the string : This is w3resource.com

Expected Output:
Total number of words in the string is: 3

Filename: wordcount.c

2. Write a program in C to count the total number of alphabets, digits and special characters in a
string.

Test Data :
Input the string : Welcome to w3resource.com

Expected Output:
Number of Alphabets in the string is: 21
Number of Digits in the string is: 1
Number of Special characters in the string is: 4

Filename: stringcount.c

You might also like