
Returning Pointer To Pointer From Function
: I would appreciate some advice on how to correctly write a function
: prototype, and how to use the variable that was passed. I'll explain
: what the situation is. Before I gave up on this, I was getting syntax
: errors no matter what I tried.
: At the top of the program, I set up a define
: "define TYPE_16BIT_UNSIGNED unsigned small". In a function, I used
: malloc to get a pointer to an array of TYPE_16BIT_UNSIGNED. This was a one
: dimensional array which stored a two dimensional image, one row after the
: other. In the function, I used malloc to allocate memory for an array of
: pointers to variables of type TYPE_16BIT_UNSIGNED. Each element in the
: pointer array was then initialized to point to the first element of a row
: in the first array. What I couldn't figure out was how to set up the
: function prototype so that I could return the pointer to the image array,
: and the pointer to the array of pointers.
: If the variables were local to the function, I think that the definitions
: would be similar to:
: TYPE_16BIT_UNSIGNED *image_ptr; /* pointer to image array */
: TYPE_16BIT_UNSIGNED **image_row_ptr; /* pointer to array of row pointers */
: After initialization, I could access elements in the image array by writing:
: image_row_ptr[i][j] = 0;
: But, the compiler didn't seem to like me defining the image_row_ptr in
: the function prototype as:
: TYPE_16BIT_UNSIGNED ***image_row_ptr
: Does anyone have a suggestion? Please send it to me by e-mail if you
: do. Thanks.
: --
: ============================================================================
: Systems Analyst II | WWW: http://www.ualr.edu/~clscott/
: Computing Services - SUB203C | Voice: (501) 569-3342
: University of Arkansas at Little Rock |
: Little Rock, AR 72204 |
: ============================================================================
--
***************begin r.s. response******************
try using a
typedef
rather than
#define
for this ...
***************end r.s. response********************
Ralph Silverman