1. Dashboard
  2. Forum
    1. Unresolved Threads
  3. Members
    1. Recent Activities
    2. Users Online
    3. Team-Mitglieder
    4. Trophy
    5. Search Members
  4. Lexicon
  • Login
  • Register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Pages
  • Forum
  • Lexikon
  • More Options
  1. Informatik Forum
  2. Webmaster & Internet
  3. Development

C Array / Pointer - Frage

  • Sandybutt
  • March 13, 2009 at 11:59 AM
  • Thread is Unresolved
  • Sandybutt
    8
    Sandybutt
    Mitglied
    Reactions Received
    4
    Points
    554
    Posts
    99
    • March 13, 2009 at 11:59 AM
    • #1

    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?"

  • daywalker
    4
    daywalker
    Mitglied
    Points
    140
    Posts
    27
    • March 13, 2009 at 12:13 PM
    • #2

    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 :)

    11 Steffen Hofmann Fussballgott!

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

  • Kampi
    27
    Kampi
    Mitglied
    Reactions Received
    193
    Points
    7,828
    Posts
    1,468
    • March 13, 2009 at 12:19 PM
    • #3

    [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).

  • Sandybutt
    8
    Sandybutt
    Mitglied
    Reactions Received
    4
    Points
    554
    Posts
    99
    • March 13, 2009 at 12:29 PM
    • #4

    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?"

  • 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!

Register Yourself Login

Rechtliches

Impressum

Datenschutzerklärung