When to use size_t?
I understand that size_t was defined as a type to hold the size of an object in C. For instance, strlen returns a size_t since the length of a string cannot be negative. For array indexes, size_t is also better. But can I use size_t for holding values that I know cannot be negative? For instance, I have a list of rectangles and I want to calculate the sum of their areas. Is size_t OK in this case? Thanks.
Posted Dec 1, 2019, 2:00 PM UTC
4064