sizeof

Dieses Schlüsselwort liefert die Größe einer Variable / eines Datentyps in Byte:

#include <iostream>
using namespace std;

int main()
{
  cout << "Datentyp "   << "Bytes"          << endl;
  cout << "-----------------"               << endl;
  cout << "bool: "      << sizeof(bool)     << endl;
  cout << "char: "      << sizeof(char)     << endl;
  cout << "short: "     << sizeof(short)    << endl;
  cout << "int: "       << sizeof(int)      << endl;
  cout << "long: "      << sizeof(long)     << endl;
  cout << "long long: " << sizeof(long long)<< endl;
}


Übersicht Keywords C++