Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!davis From: davis@pacific.mps.ohio-state.edu ("John E. Davis") Newsgroups: comp.lang.c Subject: prototyping (oh no! not again??) Message-ID: Date: 26 Nov 90 19:40:44 GMT Sender: news@pacific.mps.ohio-state.edu Reply-To: davis@pacific.mps.ohio-state.edu (John E. Davis) Distribution: comp Organization: "Dept. of Physics, The Ohio State University" Lines: 50 Hi, Sorry about this, I am sure many are sick of these type of questions. I have a function that takes a 2-d array of unknown dimension and does things with it. How do I declare and call it? I tried this: double trace(double **matrix, int dim) { int i; double t; t = 0.0; i = 0; while(i++ < dim) t = t + matrix[i][i]; return t; } int main() { double m[10][10],t; . . t = trace(m,10); . . } This dumps core because of segmentation fault. However, if I prototype trace as: double trace(double matrix[10][10],int n) then the program is fine. However, it looses its generality. What is wrong with the first prototype? I am sure I am doing something wrong and there is a big lesson in store for me. -- John bitnet: davis@ohstpy internet: davis@pacific.mps.ohio-state.edu