[gelöst] Zweidimensionales Array an Funktion übergeben



  • Hallo,

    ich sehe gerade einfach nicht, was ich in folgendem Code falsch mache. Mein Vorlagencode (http://openbook.galileocomputing.de/c_von_a_bis_z/c_013_010.htm#RxxobKap0130100400284F1F03A18C) code läuft problemlos, obwohl es doch prinzipiell die gleiche Prozedur ist 😕
    Kann mir jemand sagen, was ich hier falsch mache?

    #include <stdlib.h>
    #include <stdio.h>
    
    #define SIZE 5;
    
    void function(int array[][SIZE])
    {
    	array[0][0] = 3;
    }
    
    int main(void)
    {
    	int array[SIZE][SIZE];
    	function(array);
    }
    

    EDIT: Die Fehlermeldung ist die folgende:

    gcc -o test test.c
    test.c:6: error: expected ‘]’ before ‘;’ token
    test.c: In function ‘function’:
    test.c:8: error: ‘array’ undeclared (first use in this function)
    test.c:8: error: (Each undeclared identifier is reported only once
    test.c:8: error: for each function it appears in.)
    test.c: In function ‘main’:
    test.c:13: error: expected ‘]’ before ‘;’ token
    test.c:13: error: expected statement before ‘]’ token
    test.c:14: error: ‘array’ undeclared (first use in this function)
    


  • Problem gelöst:
    Ich habe einen strichpunkt hinter dem #define statement 🙄



  • Nimm mal das ; aus Zeile 5 raus. 😉



  • Siegfried1 schrieb:

    Problem gelöst:
    Ich habe einen strichpunkt hinter dem #define statement 🙄

    Hehe, der Klassiker... 😃


Log in to reply