User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 362,340 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,717 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:

returning three dimensional array

Join Date: Oct 2007
Posts: 41
Reputation: mank is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
mank mank is offline Offline
Light Poster

Re: returning three dimensional array

  #3  
Nov 2nd, 2007
For example

multi_return.c: In function ‘funct1’:
multi_return.c:27: warning: return from incompatible pointer type
multi_return.c:27: warning: function returns address of local variable

  #include <stdio.h>

 float Mat[4][4][4];

float *funct1(void)
{
float Mat[4][4][4]={
1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,

1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,

1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,

1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,
1.2,1.3,1.4,1.5,};
return Mat;
}

void funct2()
{
int i,j,k;
float *Mat;
Mat=funct1();

         for(k=0; k<4;k++)
         {
           for (i=0; i<4; i++)
	   {
		 for (j=0; j<4; j++)
		 {
		//    printf(" %f ", Mat[k][i][j]);
		 }
		 printf("\n");
	   }
		 printf("\n");
         }

}
         
        int main() {
        funct2();
        }
Reply With Quote  
All times are GMT -4. The time now is 11:08 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC