Simple, Pass Pointer of an Array to function 
Author Message
 Simple, Pass Pointer of an Array to function

I need to pass a pointer to a multidimensional array to a function.  

long Array[1][2];
long Arr[1][2];
Array[1][1] = 1;
Array[1][2] = 2;

Arr *Array;
Function(Arr);

What am I missing.

ps.  Sorry for the stupid question!

--
Sahlem Kharaka
Software Engineer

www.touchsource.com



Sun, 06 Jun 1999 03:00:00 GMT  
 Simple, Pass Pointer of an Array to function

Quote:

> I need to pass a pointer to a multidimensional array to a function.

> long Array[1][2];
> long Arr[1][2];
> Array[1][1] = 1;
> Array[1][2] = 2;

> Arr *Array;
> Function(Arr);

> What am I missing.

> ps.  Sorry for the stupid question!

> --
> Sahlem Kharaka
> Software Engineer

> www.touchsource.com

You have created a pointer (Array) to an array (Arr), but you didn't
initialize it.

        long Array[1][2];
        long Arr[1][2];
        Array[1][1] = 1;
        Array[1][2] = 2;

        //Arr *Array;

        Arr * pArr;
        pArr = Arr;

        Function(pArr);

--
Cecil Galbraith

Free programmer's utilities and MFC tips at
http://www.concentric.net/~cgalbrai



Sun, 06 Jun 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. passing pointer to a function expecting an array

2. pass a pointer to array of structs to functions

3. passing array of pointers to function

4. Newbie question: Pointer to an array and passing it into a function

5. Passing 2-D pointer to array to function

6. Passing an array of pointers to functions

7. function pointers and function pointers array

8. Passing pointers to arrays of pointers....

9. How to use (pointer to function), and function and pointer to (pointer to function)

10. Pointer to function passed to varargs function

11. Novice: Passing a function pointer to a function

12. Prototyping a function passed a pointer to a function

 

 
Powered by phpBB® Forum Software