C Array / Pointer - Frage

  • Kann mir vielleicht jemand erklären, was in C der Unterschied zwischen

    Code
    float (*Q)[4][3]

    und

    Code
    float *Q[4][3]

    ist?

    "I don't think that Debian can really compete with Gentoo. Sure it might be okay, but when it comes to dependencies, you probably are still going to have to get them all on your own. Or is there something like portage in the Debian world as well?"

  • [INDENT]

    Quote


    float (*Q)[4][3];

    [/INDENT]ein pointer auf ein 4x3 array bestehend aus 4x3 floats.

    [INDENT]

    Quote

    float *Q[4][3];

    [/INDENT]ein array bestehend aus 4x3 pointern vom typ float.

    Willfähriges Mitglied des Fefe-Zeitbinder-Botnets und der Open Source Tea Party.

    Edited once, last by Kampi (March 13, 2009 at 12:23 PM).

  • Warum ist dann folgender Code gültig:

    Code
    main() {
        float a[4][3];
        float (*b)[3];
        b = a;
    }

    und dieser nicht:

    Code
    main() {
        float a[4][3];
        float *b[3];
        b = a;
    }

    Ich hätte mir eigentlich genau das Gegenteil erwartet?

    Edit: Ah, jetzt wirds mir langsam klar. Man kann ja float a[4][3] quasi als 4 Pointer auf ein float[3] - Array betrachten. Der zweite Fall schlägt demnach fehl, weil die Zuweisung von einem Pointer auf ein float[3] - Array nicht vereinbar ist mit einem float[4][3] - Array. Check! Dankeschön!

    "I don't think that Debian can really compete with Gentoo. Sure it might be okay, but when it comes to dependencies, you probably are still going to have to get them all on your own. Or is there something like portage in the Debian world as well?"

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!