Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


multi dimensional arrays

Posted on 1999-07-22
Medium Priority
Last Modified: 2010-04-15
int n[5];

void func( int * pn )
{ .... }

func( n );

this is clear.
What to write in the 'func()' call in that case:

int n[5][5];

void func( int ** ppn )
{ .... }

func( ???? );

Question by:dib
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Author Comment

ID: 1263787
Edited text of question.
LVL 10

Accepted Solution

rbr earned 200 total points
ID: 1263788
void func (int arr[][5])

LVL 10

Expert Comment

ID: 1263789
You have to know at the number of cols of your matrix. Another better way if the dimensions differs and you want to use the same function sveral times is to use the following structure

struct my_arr {
      size_t rows;
      size_t cols;
      int **pparr;

struct my_arr *init_array (size_t cols,size_t rows)
      struct my_arr *parr;
     int i;

      parr = calloc (1,sizeof (struct my_arr));

     parr->pparr = calloc (cols,sizeof (int *));
     for (i=0;i<rows;i++)       {
            parr->pparr[i] = calloc (rows, sizeof (int));
      return (parr);
void clear_array (struct my_arr *parr)
      int i;
         for (i=0;i<parr->rows;i++)       {
      free (parr->pparr);
      free (parr);


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question