struct MyStuct{
int a;
int b;
int c[2];
int d[2];
};
static struct MyStuct test [2][3] =
{
// | COL 0 | | COL 1 | | COL 2 |
/* ROW 0 */ { {1,1,{1,1},{1,1}}, {2,2,{2,2},{2,2}}, {3,3,{3,3},{3,3}} },
/* ROW 1 */ { {7,7,{7,7},{7,7}}, {8,8,{8,8},{8,8}}, {9,9,{9,9},{9,9}} }
};
Ihre Matrix Deklaration hat die Struktur als Typ zu verwenden, dh struct MyStuct test
Nur für den Test:
#include <stdio.h>
int main (void)
{
struct MyStuct{
int a;
int b;
int c[2];
int d[2];
};
struct MyStuct test [2][3] =
{
// | COL 0 | COL 1 | COL 2 |
/* ROW 0 */ { {1,1,{1,1},{1,1}}, {2,2,{2,2},{2,2}}, {3,3,{3,3},{3,3}} },
/* ROW 1 */ { {7,7,{7,7},{7,7}}, {8,8,{8,8},{8,8}}, {9,9,{9,9},{9,9}} }
};
for (size_t i=0; i< 2; i++)
{
for (size_t j=0; j<3; j++)
{
printf("test[%zu][%zu].a = %d\n", i, j, test[i][j].a);
printf("test[%zu][%zu].b = %d\n", i, j, test[i][j].b);
for (size_t z=0; z<sizeof(test[i][j].c)/sizeof(test[i][j].c[0]); z++)
{
printf("test[%zu][%zu].c[%zu] = %d\n", i, j, z, test[i][j].c[z]);
}
for (size_t z=0; z<sizeof(test[i][j].c)/sizeof(test[i][j].c[0]); z++)
{
printf("test[%zu][%zu].d[%zu] = %d\n", i, j, z, test[i][j].c[z]);
}
printf("\n");
}
}
return 0;
}
'scheint nicht zu funktionieren.' ... wie genau? –
@SouravGhosh Ich denke, es kompiliert nicht :) – niceman
@niceman und welcher Compiler keine Debug-Nachricht erzeugt? :) –