Basic Types in C
Some Common Data Types
Type | Common Size in Bytes | Interpretation |
---|---|---|
char | 1 | one ASCII character |
int | 4 | signed integer |
float | 4 | single-precision floating-point number |
double | 8 | double-precision floating-point number |
A surprising quirk about C is that the sizes of some types can be different in different compilers and platforms! So this table lists common byte sizes for these types on popular platforms.
Characters
Every character is corresponds to a number. The mapping between characters and numbers is called the text encoding, and the ubiquitous one for basic characters in the English language is called ASCII. Here is a table with some of the most common characters in ASCII:
For all the characters in ASCII (and beyond), see this ASCII table.
Booleans
C does not have a bool
data type available by default.
Instead, you need to include the stdbool.h
header:
#include <stdbool.h>
That lets you use the bool
type and the true
and false
expressions.
If you get an error like unknown type name 'bool'
, just add the include above to fix it.