Lesson 6 / 36
Data Types
How many bytes a value takes and how they're read.
The basic types
char 1 byte · int 4 bytes · float 4 bytes · double 8 bytes · bool via <stdbool.h>. Modifiers: short, long, long long, unsigned.
Check a size
sizeof reports bytes at compile time.
#include <stdio.h>
int main(void) {
printf("int is %zu bytes\n", sizeof(int));
return 0;
}
Output:
int is 4 bytes
Overflow wraps
unsigned char c = 255; c = c + 1; makes c become 0. Integer types wrap around at their limits.