What is the size of int, long type as per C++ standard?

C++Server Side ProgrammingProgramming

Here we will see what are the sizes of the int and long type data in C++. The sizes are depending on the system architecture and the Operating system.

So in the 32-bit system, the standard is ILP32. In this standard the int, long and the pointer variables are of 32-bits.

For the 64-bit system there are two variations. For Linux Operating system the standard is LP64. Here long and pointer are of 64-bits, but int are of 32-bits. For the Windows operating system, the standard is LLP64. Here long long is 64-bit, but int and long are of 32-bits.


#include <iostream>
using namespace std;
int main() {
   cout << "Size of int: " << sizeof(int) * 8 << " bits" << endl;
   cout << "Size of long: " << sizeof(long) * 8 << " bits" <<endl;
   cout << "Size of long long: " << sizeof(long long) * 8 << " bits"<< endl;


Size of int: 32 bits
Size of long: 32 bits
Size of long long: 64 bits
Published on 02-May-2019 16:01:09