Skip to content
doubtly

1 answer

Best answer

It is the type of the result of the sizeof operator. size_t is used to express the size of something or the number of characters in something. For example, it is the type that you pass to malloc( ) to indicate how many bytes you wish to allocate. Or it is the type returned by strlen( ) to indicate the number of characters in a string. Each implementation chooses a type like unsigned int or unsigned long (or something else) to be its size_t, depending on what makes most sense. Each implementation publishes its own choice of size_t in several header files like 'stdio.h', 'stdlib.h', etc. In most implementations size_t is defined as:

typedef unsigned int size_t ;

This means that on this particular implementation size_t is an unsigned int. Other implementations may make other choices. What is important is that you should not worry about what size_t looks like for a particular implementation; all you should care about is that it is the right type for representing object sizes and count.

Doubtly · 11 Jun 2022 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.