Skip to content
UPEEC

C Data Types and Format Specifiers

int, char, float, double and fixed-width types — and how printf prints them.

Beginner
Comments 0
TypeTypical sizeprintf
char1 byte%c
int4 bytes (2 on AVR!)%d
long4–8 bytes%ld
float4 bytes%f
double8 bytes%f (%lf in scanf)

Sizes depend on the platform, so embedded code uses <stdint.h>: uint8_t, int16_t, uint32_t — exact widths everywhere.

uint16_t adc = 1023;
printf("ADC = %u, V = %.2f\n", adc, adc * 5.0 / 1023);

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.