0 votes
91 views
in Discuss by (98.9k points)
edited
What is size_t ?

1 Answer

0 votes
by (98.9k points)
edited by
 
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.

Related questions

0 votes
1 answer 130 views
0 votes
1 answer 122 views
0 votes
1 answer 238 views
0 votes
1 answer 145 views
0 votes
1 answer 79 views
asked May 14, 2022 in C program by Doubtly (98.9k points)
0 votes
0 answers 48 views
asked Jun 11, 2022 in Discuss by nehapatil (3.2k points)

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

537 users

...