home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!psinntp!sugar!martink
- From: martink@NeoSoft.com (Martin Koistinen)
- Subject: ** in C
- Organization: NeoSoft Communications Services -- (713) 684-5900
- Date: Tue, 5 Jan 1993 03:49:03 GMT
- Message-ID: <C0D3xs.1y2@NeoSoft.com>
- Lines: 46
-
- I have a function that needs a 2D array. So I declared it as follows:
-
- double *My_Function(double A[3][3])
- {
- static double R[3];
- .
- .
- .
- return((double *)&R);
- }
-
- I have a header file that declares it as:
-
- double *My_Function(double **)
-
- My code refers to it as:
-
- double M[3][3];
- double *p;
-
- p = My_Function(M);
-
- I have two questions:
-
- 1) Is there any reason why I shouldn't return a pointer to a static from a
- function? I realize that I may get bad results if I try to reference the
- pointeaafter I do another call to the function or try to use it twice in
- the same statement but is there anything else?
-
- 2) My compiler gives me a warning that I am passing the function something
- other then what it wants. Why?
-
- My code seems to work great but I feel better when my compiler doesn't
- give me warnings. It was my understanding that n Dimensional arrays break
- down into pointers (n references).
-
- I am curious about the static stuff because I have never seen this done by
- others.
-
- Please respond via email - Thanks
- Martink@neosoft.com
- --
- ______
- \ / 95 percent of the symbols used in this | Martin J. Koistinen
- \ / post were made of recycled characters | martink@neosoft.com
- \/ ----------- Recycle today for tomorrows future -------------
-