pointer to flexible array of structures in other structure



I'm trying to put pointer to flexible array of structures in other
structure. I want to have pointer to array of pixels in screen
structure. Here is mine code, but I think it isn't quite all right:

struct pixel
{
int x;
int y;
int color;
};

struct display
{
pixel *screen;
};

Now I would like to do something like that (to have screen made of 10
pixels):

struct display scr;
scr.screen = (struct pixel*)malloc(10*(sizeof(struct pixel)));
scr.screen[0].x = 10;

and it is working, but what is worrying also
scr.screen[11].x = 10;

or
scr.screen[100].x = 10;

is working. I don't now what is wrong. I'm not sure but I think I'm
making mistake when defining structures. How should I define flexible
array of structures in structure? And how should I point it?

Thanks for help and Merry Xmas,
John

.



Relevant Pages

  • Re: key to speed - use byte array instead of writing to locked image bytes
    ... you just modify integers in the pixels array. ... handle when you are completely finished with the bitmap. ... PixelFormat.Format32bppPArgb, pointer); ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: user arrays and VARIANT *
    ... pointer to an array of 192x256 BYTES in a VARIANT object. ... You can also use VARIANT, but if you do, you have to initialize it and clean ... If my image is 256 pixels wide and 192 pixels high, ...
    (microsoft.public.vc.mfc)
  • Re: Pointers
    ... does NOT represent a pointer. ... data structure the pointer points to... ... Consider a class of "Image" whith an array of pixels. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: char **argv & char *argv[]
    ... "pointer to pointer to char". ... >> pointer)) pointing to the first element of an array. ... so we have to start adding more context. ... type "pointer to char", rather than "array MISSING_SIZE of char". ...
    (comp.lang.c)
  • Re: why cannot assign to function call
    ... hypothetical C-like languages, ... sizeof business would still indicate that a pointer was being passed. ... talk about variables of an array type. ... the earlier version of the standard didn't have numbered ...
    (comp.lang.python)