C Data Types Flashcards
int
Data Type
Stores a regular integer, defaulting to 32 bits in size
double
Data Type
Holds a large floating point number
char
Data Type
Holds a single 1 byte character
void
Data Type
Indicates “no type” and used to say a function returns nothing, or a pointer has no type as in void *thing.
enum
Data Type
Enumerated types, work as integers, convert to integers but give you symbolic names for sets. Some compilers will warn you when you don’t cover all elements of an enum in switch-statements
unsigned
Type Modifier
Changes the type so that it does not have negative numbers, giving you a larger upper bound but nothing lower than zero.
signed
Type Modifier
Gives you negative and positive numbers but halves your upper bound in exchange for the same lower bound negative.
long
Type Modifier
Uses a larger storage for the type so that it can hold bigger numbers, usually doubling the current size.
short
Type Modifier
Uses smaller storage for the type so it stores less, but takes half the space.
const
Type Qualifier
Indicates the variable won’t change after being initialized.
volatile
Type Qualifier
Indicates that all bets are off, and the compiler should leave this alone and try not to do any fancy optimizationis to it. You usually only need this if you’re doing really weird stuff to your variables.
register
Type Qualifier
Forces the compiler ot keep this variable in a regestier, and the compiler can just ignore you. These days compilers are better at figuring out where to put variables, so only use this if you actually can measure it improving the speed.
int8_t
Type Size
defined in stdint.h
8 bit signed integer
uint8_t
Type Size
- defined in stdint.h*
8 bit unsigned integer
int16_t
Type Size
defined in stdint.h
16 bit signed integer