Char Keyword
In C programming, the char
keyword is used to declare character data types.
It represents a single character and can hold ASCII values ranging from 0 to 255. The char
data type is commonly used to store characters, such as letters, digits, or symbols.
Here's an example of using the 'char' keyword to declare a variable:
This code declares a char
variable named letter
and initializes it with the character 'A'.
The char
data type is commonly used for storing individual characters, such as alphabets, digits, or special symbols.
In C, characters are internally represented as small integers using ASCII encoding. For example, the character 'A' has an ASCII value of 65, 'B' has 66, and so on.
You can perform various operations on char
variables, including arithmetic operations, comparisons, and printing using the appropriate format specifier, %c.
It's important to remember that char
variables can store only a single character.
To store multiple characters or strings, you would need to use arrays of char
.