liveBook · Manning

Size_t

size_t is an unsigned integer type in C and C++ used to represent object sizes and related counts.

How 2 Manning books explain it

Modern C

size_t is an unsigned integer type provided by the C standard library for representing object sizes and related counts.

How it is used
Uses size_t to express object sizes, cardinalities, and related counts with semantic type information.
How deep it goes
Explains size_t’s semantic classification and +, -, and * rules, but defers detailed overflow handling.
Examples
Demonstrates grouped expressions, unary operators, and values 45 and 7 producing 76 and 31.
What you can do after
Evaluate/understand size_t expressions and recognize when unsigned results are representable or overflow.

Read how Modern C explains size_t →

100 C++ Mistakes and How to Avoid Them

size_t is an unsigned integer type capable of representing the size of any object in C++.

How it is used
Supports type selection for loop indexes, where compiler deduction can yield size_t for container sizes.
How deep it goes
Defines size_t as an unsigned type able to represent any object size and explains wraparound in reverse loops.
Examples
Uses a vector reverse loop whose auto index underflows at zero and causes an out-of-bounds access.
What you can do after
Diagnose unsigned reverse-loop underflow and use int for the loop variable in this case.

Read how 100 C++ Mistakes and How to Avoid Them explains size_t →

Also covered in

Related concepts

Questions about size_t

What is size_t?

size_t is an unsigned integer type in C and C++ used to represent object sizes and related counts.

Which Manning books explain size_t?

Modern C and 100 C++ Mistakes and How to Avoid Them.

What is size_t a kind of?

Size_t is a kind of unsigned integer. An unsigned integer is an integer type or representation whose values are nonnegative.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.