typedef struct {
char name[][MAX1];
char state[][MAX1];
char id[]MAX1];
} Station;
for some reason i can't get this to compile.
but when i make each of the arrays to one dimension it compiles.
am i able to have 2d arrys in structures??
This is a discussion on structure question within the C Programming forums, part of the General Programming Boards category; typedef struct { char name[][MAX1]; char state[][MAX1]; char id[]MAX1]; } Station; for some reason i can't get this to compile. ...
typedef struct {
char name[][MAX1];
char state[][MAX1];
char id[]MAX1];
} Station;
for some reason i can't get this to compile.
but when i make each of the arrays to one dimension it compiles.
am i able to have 2d arrys in structures??
typedef struct {
char name[][MAX1];
char state[][MAX1];
char id[]MAX1];
} Station;
These are not considered 2D arrays. They are incorrect. You can use 2D arrays, you just have to specify the size:
There is no point in having your 2D array as you have described it. Remember this:Code:struct mystruct { char array[3][45]; };
You can only use empty [] for an array argument when you are providing the data for it at that time:
Quzah.Code:struct somestruct mytable[] = { { "hello", 20, 4.33 }, { "whee", 453, 1.302 }, { "goodbye", 3, 0.12 }, { "", 0, 0.0 } };
Hope is the first step on the road to disappointment.