Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!mnetor!seismo!mcvax!inria!imag!lifia!fano From: fano@lifia.UUCP Newsgroups: comp.lang.c Subject: help needed about dynamic space allocation Message-ID: <1046@lifia.UUCP> Date: Fri, 21-Nov-86 13:12:26 EST Article-I.D.: lifia.1046 Posted: Fri Nov 21 13:12:26 1986 Date-Received: Sat, 22-Nov-86 06:46:39 EST References: <13802@amdcad.UUCP> <359@prairie.UUCP> Reply-To: fano@lifia.UUCP (Rampa*) Organization: LIFIA-IMAG, Un. of Grenoble, France Lines: 49 forgive the ignorance of a novice C-programmer: I need advice on dynamic space allocation for multidimensionnal arrays: Here is a way I have implemented dynamic allocation for a 2 X 2 matrix named sig in a C-source file named combin1.c: (I'll explain further the reason why I'm not satisfied with that solution) BEGINNING OF THE EXAMPLE: float **sig; /* matrix declaration */ .... sig = (int *)malloc(n * sizeof(int)); /* allocates space for sig */ for ( i = 0; i < n; i++) /* lines adresse */ { sig[i] = (float *)malloc(n * sizeof(float));/* allocates space for */ } /* columns of line i */ .... for (i = n-1 ; i >= 0; i--) { free(sig[i]); /* desallocates space */ } free(sig); END OF THE EXAMPLE during the compiling time, I get the following warning: "combin1.c", line 220: warning: illegal pointer combination any-way the program runs, and gives the desired results. The compiler message suggests that I didn't use the proper way to implement matrix dynamic allocation. So, could someone over there give me advices for a cleaner solution. Thanx. -- fano rampa* /////////////////////////////////////////////////////////////////////////////// "Carmen lips are more exciting than Common lisp..." -G.Bizet- fano@lifia.UUCP or mcvax!lifia!fano