#include <iostream>
#include <iomanip>

using namespace std;

void ausgabe(int &);

int main()
{
    int zahl=0;
    cout << "Bitte eine Zahl eingeben: ";
    cin >> zahl;
    ausgabe(zahl);
    return(0);
}

void ausgabe(int & zahl)
{
    char* inhalt = (char*)&zahl;
    char tmp;
    int divid;
    cout << "Eigegebene Zahl      : " <<  zahl << endl;
    cout << "Adresse der Variable : " << &zahl << endl;
    cout << "Groesse der Variable : " << sizeof(zahl) << " Bytes = " << sizeof(zahl)*8 << " Bit" << endl;
    cout << "Byteweiser Inhalt des Speichers in Binaerdarstellung (Big Endian):" << endl;
    cout << "Byte #  | Inhalt   " << endl;
    cout << "--------|----------" << endl;
    for(int i = 0; i< sizeof(zahl);i++)
    {
	cout << setw(7) << i << " | ";
	tmp=(unsigned int)inhalt[i];
	for(int j=7;j>=0;j--)
	{
	    divid = 1 << j;
	    (inhalt[i] & divid)?cout << "1" : cout << "0";
	    //cout << tmp / divid;
	    //tmp -= (tmp / divid) * divid;

	}
	cout << endl;
    }
}
