J
John Gerrard
Hi, this is my second week in C and this group.
This code compiles cleanly.
//a bit of this is copied from
//page 133 of K&R, 2nd edition
struct key
{
char *word;
int count;
} keytab[]=
{
{"auto",0},
{"break",0}
};
My code, which represents what I want to do, does not. I am sure it is
a syntax problem but could someone guide me on the type of syntax I
should use. My code for the structure is below.
struct teststr
{
char *word;
int[][] array;
} test[]=
{
{"1",{{1,2,3},{4,5,6},{7,8,9}},
{"2",{{1,2,3},{4,5,6}}
};
I don't want you to think I am lazy and not coding this myself. So here
is what I think. I can't have variable length arrays in the struct. I
think my approach should create a struct so that "array" is a pointer
to each of the variable length arrays so that each element in array
"test" is the same size. I would appreciate someone confirming this or
putting me on the right track, (and if it's difficult, a bit of
pseudocode so I get there).
Thank you again
John
This code compiles cleanly.
//a bit of this is copied from
//page 133 of K&R, 2nd edition
struct key
{
char *word;
int count;
} keytab[]=
{
{"auto",0},
{"break",0}
};
My code, which represents what I want to do, does not. I am sure it is
a syntax problem but could someone guide me on the type of syntax I
should use. My code for the structure is below.
struct teststr
{
char *word;
int[][] array;
} test[]=
{
{"1",{{1,2,3},{4,5,6},{7,8,9}},
{"2",{{1,2,3},{4,5,6}}
};
I don't want you to think I am lazy and not coding this myself. So here
is what I think. I can't have variable length arrays in the struct. I
think my approach should create a struct so that "array" is a pointer
to each of the variable length arrays so that each element in array
"test" is the same size. I would appreciate someone confirming this or
putting me on the right track, (and if it's difficult, a bit of
pseudocode so I get there).
Thank you again
John