Mail Archives: djgpp/1996/07/17/00:15:47
Bob Platko (platko AT ix DOT netcom DOT com) wrote:
: I have a few questions for the C experts out their.
: The reason I posted this in the DJGPP newsgroup is because many of
: the code that I see does not seem to compile under GCC, since most
: compilers don't strictly follow the ANSI C standard or they mix C and
: C++. (And I use GCC a thousand times to one than TCC) :)
: Anyways, I'm writing a program that handles some 3d graphic routines.
: Yet, I am having some problems with some non-graphic related stuff.
: So here's my questions:
: 1. How can you pass undetermind sized arrays to a function?
: Let's say I have a function:
: void RotateObject(int x, int y, int z, object[][][])
: See the []'s. I have a 3 dimention array that holds the object:
: object[Num_of_Polys][Poly_Points][Coordinates]
: Now each object being feed to the function has a diffrent number
: of polygons, or sides. Thus, the Num_of_Polys will be different.
: Heres what I came up with, but I can't get it to work.
: void RotateObject(int x, int y, int z, int num_of_sides, object);
: ^^^^^^
: I know that is wrong. How do I get around it. BTW, object is
: an integer.
I do not claim to be a guru, and I have not used djgpp very long but..
The thought of defining a structure for the object, containing the number
of Polygons, Polygon Points, Coordinates comes to mind.
struct point {
int x,y,z;
};
typedef struct point POINT;
struct object {
int Num_of_Polys;
int Poly_Points;
Points *Point;
};
typedef struct object OBJECT;
This is just off the top of my head, but I'm sure that's a start..
: 2. How do I return multiple values from a function?
: The function described above must return the new coordinates.
: I heard besides using return, you can also use a pointer to
: return the value through a argument in the fuction. How do I
: do this with arrays?
Returning a structure again comes to mind.
You could use the above (more or less) and define your
function to return an OBJECT.
Make sure and typecast everything though...or you may loose some of the
information you need. And also, be careful how you allocate the memory
on the return object.
These are just suggestions, but I figured I would give my 2 cent's worth.
Maybe someone can tell me if there is anything wrong with doing it this way
also.
Eric Bresie
breezy AT dali DOT math DOT swt DOT edu
: Thanks for any help.
: BP
- Raw text -