Mail Archives: djgpp/1996/07/17/00:55:16
Reply to message 2191609 from LOLO AT EINEV0 DOT E on 07/15/96 11:27AM
>typedef struct
>{ long width;
> long height;
> char pixels[width*height];
>} toudoudou;
>
>but the use of the variables width and height for char pixels[]
>don't work with DJGPP.
>Is it because the 2 variables and pixels[] are in the same structure
>definition ?
>How to do that ?
Without some specially-written extensions, what you're trying to do
is just not possible in C AFAIK. The only truly reliable way to do
something like that is this:
typedef struct
{ long width;
long height;
char *pixels;
} toudoudou;
toudoudou.width=X;
toudoudou.height=Y;
toudoudou.pixels = (char *)malloc( sizeof(char) * width * height );
I saw another suggestion before mine; I honestly couldn't tell you how
likely that is to work, except that in C you can access a pointer as an
array and vice versa, and C doesn't do any range checking no matter
which method you use.
John
- Raw text -