![]() |
| | #1 |
| Registered User Join Date: Feb 2008
Posts: 5
| struct pointers I was wondering how it would be done to point to struct, like this you have two dif structs Code: typedef struct {
float face1,face2,face3;
char name[200];
int num_objs;
} object_list;
typedef struct {
scene_name
}scenes;
object_list obj[50];
scenes scene[50];
(this is pseudo and what i want todo) scene[0].obj[0].numobj; result with how many objects there are in scene 0, right now i add the start object and the end object into the scene struct so, when drawing the 3d object, i do this more or less. Code: for (counter=startobj;counter<endobj;counter++) Any help are appricated! ![]() - seidel |
| seidel is offline | |
| | #2 |
| Super Moderator Join Date: Sep 2001
Posts: 4,680
| If you're asking how to iterate through a series of structs, you have at least two options. Here they are in somewhat-pseudo-code: As an array Code: my_type objects[50];
int length = 50;
...
for(i = 0; i < length; i++) {
// Do some stuff with objects[i]
}
Code: struct my_type {
int data[50];
struct my_type * next;
} current;
...
for(current = start; current.next != NULL; current = current.net) {
// Do some stuff with current
}
|
| sean is offline | |
| | #3 |
| Registered User Join Date: Jan 2007 Location: Euless, TX
Posts: 135
| For one thing, struct scene DOES NOT contain an 'obj', so your 'scene[0].obj[0].numobj;' is completely bogus. To do what you want to do, you would have to include the structure 'object_list' INSIDE your scene struct. Code: typedef struct {
float face1,face2,face3;
char name[200];
int num_objs;
} object_list;
typedef struct {
scene_name
struct object_list[50];
}scenes;
|
| kcpilot is offline | |
![]() |
| Tags |
| code |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Concatenating in linked list | drater | C Programming | 12 | 05-02-2008 11:10 PM |
| Global Variables | Taka | C Programming | 34 | 11-02-2007 03:25 AM |
| Function validation. | Fhl | C Programming | 10 | 02-22-2006 08:18 AM |
| Array of struct pointers - Losing my mind | drucillica | C Programming | 5 | 11-12-2005 11:50 PM |
| Pointers on pointers to pointers please... | Morgan | C Programming | 2 | 05-16-2003 11:24 AM |