C Array / Pointer - Frage
-
Sandybutt -
March 13, 2009 at 11:59 AM -
Thread is Unresolved
-
-
Das Erste ist ein Zeiger auf ein zweidimensionales Array von Float Werten.
Das Zweite ist ein zweidimensionales Array von Zeigern auf Float Werte.EDIT: Kampi hat natürlich recht
-
[INDENT]
Quote
float (*Q)[4][3];[/INDENT]ein pointer auf ein 4x3 array bestehend aus 4x3 floats.
[INDENT]
Quotefloat *Q[4][3];
[/INDENT]ein array bestehend aus 4x3 pointern vom typ float.
-
Warum ist dann folgender Code gültig:
und dieser nicht:
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!
-
Maximilian Rupp
December 27, 2024 at 12:26 AM Moved the thread from forum Programmieren to forum Development.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!