Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

zorlack

void *?

This topic is 5534 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

can someone tel me how can i use void * to create a dinamic struct which variables will be declared in the running program.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Sounds like a homework.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
depends what the dynamic struct is. If it is just references you could try

void **DynamicListToStructures;  


then you set up your dynamic list by something like:

DynamicListToStructures = new void *[HowManyStructures];
for (int i = 0; i < HowManyStructures; ++i)
{
DynamicListToStructures[ i] = (void*)MyStruct;
}


Of course... you don't want to fill up that array with a single structure like in that for loop. So use the above at your own discression...

[edit by dwarfsoft]fixed your [ i] tag so that it didn't display in italics[/edit]

[edited by - dwarfsoft on July 28, 2003 11:34:16 PM]

Share this post


Link to post
Share on other sites
what i mean is that instead of declare

struct variable
{
char name[20];
int numbre;
};

on the code page, i tell the program what i want. in other words to work like access when you are creating a table.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
void ***MyAccessTable;

MyAccessTable = new void ** [NumberOfRows];
for (int i = 0; i < NumberOfRows; ++i)
MyAccessTable[ i] = new void *[NumberOfColumns];

struct s_myStruct1
{
char name[40];
int age;
} myStruct1;

struct s_myStruct2
{
char cd_title[110];
char artist[100];
} myStruct2;

MyAccessTable[4][1] = (void*)&myStruct2;
MyAccessTable[12][3] = (void*)&myStruct1;


That enough free code for you?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!