pointer to flexible array of structures in other structure
- From: "ulyses" <ulyses@xxxxxxxxxxx>
- Date: 23 Dec 2005 13:29:40 -0800
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
.
- Follow-Ups:
- Re: pointer to flexible array of structures in other structure
- From: Keith Thompson
- Re: pointer to flexible array of structures in other structure
- From: Kenneth Brody
- Re: pointer to flexible array of structures in other structure
- Prev by Date: Re: o/p problem
- Next by Date: Re: exponentiation operator (lack of)
- Previous by thread: Help with "Concurrent Network Server" Design
- Next by thread: Re: pointer to flexible array of structures in other structure
- Index(es):
Relevant Pages
|