0

This is more kind of a confused question. size_t is said to be a type big enough to hold any sizes in C, so I searched its actual limits to learn more about it, there are two most common limits based on the machine, one is "unsigned int"(on 32bit systems) and one is "unsigned long long"(on 64bit systems).

Now, as for "unsigned long long", it makes total sense. Since it's at least around 9 million terabytes!(assuming it represents the sizes in bytes). But for "unsigned int" it can be as small as 65535!(based on Wikipedia article) So this means something around only 60 kilobytes! This huge difference is just strange, and that aside, isn't 60 kilobytes a very small size? So it means it won't be possible to have arrays bigger than 60 kilobytes on 32bit systems?! (e.g If it's an array of ints(4 bytes each), it will only be around 16000 ints).

aderchox
  • 3,163
  • 2
  • 28
  • 37
  • 3
    size_t will __always__ be big enough. Your assumption that `size_t` might be too small when `int` were 16 bits on a 32bits system is just wrong. It would just be typedefed to some other type which _is_ big enough. – tkausl Feb 09 '19 at 06:25
  • @tkausl thank you, but when is it typedefed to "unsigned int"? (probably when "unsigned int"s are big enough??) – aderchox Feb 09 '19 at 06:32
  • 3
    It's typedefed to `unsigned int` when `unsigned int` has the correct size. – tkausl Feb 09 '19 at 06:36

0 Answers0