If the size of the int is that important one can use int16_t, int32_t and int64_t (need the iostream include for that if I remember correctly). What's nice about this that int64_t should not have issues on a 32bit system (this will impact the performance though). CNN: The end of the ISS is looming, and the US could have a big problem The end of the ISS is looming, and the US could have a big problem What is the difference between .size() and .length ?

Understanding the Context

Is .size() only for arraylists and .length only for arrays? What does the C++ standard say about the size of int, long? int a[17]; size_t n = sizeof(a); On my computer, ints are 4 bytes long, so n is 68. To determine the number of elements in the array, we can divide the total size of the array by the size of the array element.

Key Insights

You could do this with the type, like this: How do I determine the size of my array in C? - Stack Overflow 82 size_t is the result type of the sizeof operator. Use size_t for variables that model size or index in an array. size_t conveys semantics: you immediately know it represents a size in bytes or an index, rather than just another integer. Also, using size_t to represent a size in bytes helps making the code portable.

Final Thoughts