Skip to content
Justice Tech School

Characters and ctype

char holds a small integer that represents a character. <ctype.h> offers isalpha, isdigit, isspace, toupper and tolower.

Example
char c = 'a';
printf("%c %d %c\n", c, c, toupper(c));
printf("%d %d %d\n", isalpha('x') != 0, isdigit('7') != 0, isspace(' ') != 0);
printf("%c\n", 'A' + 2);

Result

a 97 A
1 1 1
C

Exercise

Uppercase a char.

(c)

Quiz Test

What is a char in C?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.