Sizeof Operator in C
Level 4200 keystrokes
Uses sizeof to determine the size in bytes of different data types and structures.
C code
// Define a structure with different types1struct Data {2 char c;3 int i;4 double d;5};// sizeof gives the size in bytes; sizeof(char) is always 16printf("char: %lu\n", sizeof(char));// int is typically 4 bytes7printf("int: %lu\n", sizeof(int));// double is typically 8 bytes8printf("double: %lu\n", sizeof(double));// Includes padding: c(1) + 3 padding + i(4) + d(8) = 16 on common systems9printf("struct: %lu\n", sizeof(struct Data));Output
char: 1 int: 4 double: 8 struct: 16
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C code and how often they appear.
;× 8"× 8(× 8)× 8,× 4:× 4\× 4%× 4{× 1}× 1