Reputation: 459
I have a 2 dimensional array of structures, like so:
struct foo {
int bar;
float baz;
};
I'm actually learning about OS development right now, and one thing I'm trying to do is created a 2d array of these structures with the dimensions 80x25:
struct foo foobar[80][25];
Though I need to set it to the address 0xb8000
, since this is where the video memory starts. Is there any way I can specify the address in which my array starts?
So far I have tried doing this:
struct foo foobar[80][25];
*foobar = (struct foo) 0xb8000;
But this doesn't work. Edit: also, is doing something like this legal and/or possible to the c99 standard?
Upvotes: 0
Views: 128
Reputation: 1717
You cannot declare array at a specific location, but you can use a pointer:
struct foo *x;
x = (struct foo*)0xb8000;
This should work, but probably the operating system will complain if you tried that from a normal program, unless it is DOS or something like that.
Upvotes: 1