![]() |
| ||
| returning three dimensional array Hello I am having no problem while returning 1 dimensinal array But am having trouble with 3 dimenional array No problem with this code float Mat[][][]; But this doesnt work float Mat[][][]; Is there anyway I can return 3 dimensional arrays ? |
| ||
| Re: returning three dimensional array What are your compiler errors? |
| ||
| Re: returning three dimensional array For example multi_return.c: In function ‘funct1’: #include <stdio.h> |
| ||
| Re: returning three dimensional array I'm sure you are getting a perfectly fine return value. Your problem is that you have not supplied any type information that the compiler can use to "know" about your array. First, please see the Wikipedia here. Next, please be aware that only the first dimension can be [] in C, and only when you are not actually creating data. Other dimensions must have a size. So int Mat[][][];is an error, as is int Mat [][10][5];but void printarray( int a[][10][5], int depth );is not. However, int *Mat; knows nothing about how many dimensions the array has, or even if it really is an array.If your array has variable size dimensions, then you should use a simple flat array (or pointer) and calculate things on your own: int *index_2d_array( int *arr, int height, int width, int y, int x ) { If your Mat object is a variable-sized array, you should create a small library of functions to handle it, and place all relevant information in a structure. For example: typedef struct { Hope this helps. |
| ||
| Re: returning three dimensional array thanks I think this one works fine #include <stdio.h> |
| All times are GMT -4. The time now is 3:31 am. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC