Help with structures in V3
Displaying 1-3 of 3 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
rpgking

I just have one question about structures. Is it not possible to use a structure as an argument for a function?

for example:




struct my_structure
{
int x;
int y;
};

void do_something(my_structure a)
{
a.x = 1;
a.y = 2;
}



The above wouldn't be valid? I tried doing something like this and it doesn't compile.

EDIT: Looks like you can't declare structure types locally either.

Posted on 2004-02-21 23:43:37 (last edited on 2004-02-21 23:48:41)

mcgrue

Yeah, unfortunatly you can't pass structure instances into functions.

Here's the workaround:




#define MAX_MY_STRUCTURE 100

struct my_structure
{
int x;
int y;
};


my_structure stack_o_structs[MAX_MY_STRUCTURE];

void do_something( int idx )
{
stack_o_structs[idx].x = 1;
stack_o_structs[idx].y = 2;
}




Posted on 2004-02-22 01:17:24 (last edited on 2004-02-22 01:18:04)

rpgking

Yeah, that's what I ended up doing. It's not so bad, actually. Atleast structures are possible.

Posted on 2004-02-22 05:07:44


Displaying 1-3 of 3 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.