Andres Jaimes

How many bytes does an "int" have in c++?

By Andres Jaimes

Well, that depends on several things, like your current processor and compiler. The best way to know it, is by using the sizeof operator. Copy the following code, compile it and run it:

#include <iostream>

using namespace std;

int main() {
    cout << "char: " << sizeof(char) << endl;
    cout << "int: " << sizeof(int) << endl;
    cout << "long: " << sizeof(long) << endl;
    return 0;

Happy coding…