Ich würde gerne in einem Programm eine Oktalzahl in eine Dezimalzahl umrechnen jedoch funktioniert das noch nicht ganz.

So sieht das ganze bis jetzt bei mir aus:

        temp = zahl % 10;
        zw1 = temp;

        zahl = zahl - temp;
        temp = zahl % 100;
        zw2 = temp / 10;

        zahl = zahl - temp;
        temp = zahl % 1000;
        zw3 = temp / 100;

        zahl = zahl - temp;
        temp = zahl % 10000;
        zw4 = temp / 1000;

        zahl = zahl - temp;
        temp = zahl % 100000;
        zw5 = temp / 10000;

        r1 = zw1 * 1;
        r2 = zw2 * 8;
        r3 = zw3 * 64;
        r4 = zw4 * 512;
        r5 = zw5 * 4096;

        dezimalzahl = r1 + r2 + r3 + r4 + r5;

        printf("Die Dezimalzahl ist %.0o\n", dezimalzahl);