Created: 2023-01-10 15:25
Status: #concept
Subject: Programming
Tags: C C Data Type ASCII UTF-8
Character
A data type that stores a symbol understood by humans depending on the Character Set.
With multiple characters joined together, consecutively, they form a C String of characters.
C
We use the ASCII Character Set for determining the integer representations in C.
char l1 = '0'; // stores the character '0' into l1
char l2 = 48; // stores the character '0' into l2
A program that converts characters: from uppercase into lowercase
- This works because we subtract the integer value of the lowecase letter
'a'
and evaluates into the position of the letter in the alphabet, then we add the uppercase alphabet value'A'
. - Similarly, we can use the
<ctype.h>
Library Functions;toupper()
ortolower()
to convert the inputted character and returns it to the function call.
#include <ctype.h>
ch = toupper(ch); // converts ch to upper case
ch = tolower(ch); // converts ch to lower case
References
- C Programming, A Modern Approach, 2nd Edition, Chapter 7.3