Ich versuche, Conways Spiel des Lebens in C zu lösen. Ich habe eine .h-Datei geschrieben, die alle meine Funktionen enthält, aber ich erhalte den folgenden Fehler in der Header-Datei: Fehler: unbekannter Typ Name "Matrix"Fehler: unbekannter Typ Name struct
Dies ist der Anfang der Header-Datei, die meine Strukturdeklaration enthält und die erste Funktion:
#include<stdio.h>
#include<string.h>
#define MAX 1000
struct matrix{
int Val, Next;
};
void intro_date(int nr_elem, matrix a[MAX][MAX]){
int x,y;
printf("Enter the line and the column of the element which you wish to read within the matrix: \n");
while(nr_elem){
scanf("%d%d",&x,&y);
a[x][y].Val=1;
--nr_elem;
}
}
In C können Sie das 'struct' Schlüsselwort nicht weglassen,' Matrix a [MAX] [MAX] 'sollte' struct Matrix a [MAX] [MAX] 'sein (oder verwenden Sie ein' typedef') –
Hier wird erklärt : http://stackoverflow.com/questions/1675351/typedef-struct-vs-struct-definitionen – germanfr
Oder die Definition sollte 'typedef struct Matrix sein { int Val, Next; } Matrix; '. – JohnB