Xref: news2.mv.net comp.os.msdos.djgpp:6067 From: breezy AT dali DOT math DOT swt DOT edu (Bresie) Newsgroups: comp.os.msdos.djgpp Subject: Re: Question to the Experts Date: 16 Jul 1996 23:56:32 GMT Organization: Computer Science Department, Southwest Texas State University Lines: 82 Message-ID: <4sha7g$gj1@pirates.cs.swt.edu> References: <31E9A9BC DOT 495A AT ix DOT netcom DOT com> NNTP-Posting-Host: dali.math.swt.edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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