This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Help!!


Why do you need triple pointers?  Are you passing a two-dimensioned array to a function which changes the values?  Or are you using three-dimensioned arrays?  Two very different circumstances.

If you are passing a two-d array to a function you declare the memory for the two-d array then take the address when passing:

int **2d_array;

// allocate the memory for the 2-d arary:
// use new or malloc depending on C or C++
// I leave it as an exercise to you to figure out how to allocate
// memory for a 2-d array

//then pass the array to a function:

funct1( &2d_array );


//Inside funct1:
void funct1( int ***array )
{
     (*array)[1][1] = 1;
      return;
}


If you actually need a 3-d array then you need to figure out how to allocate the memory for it.





> > I am making a project and I have to use gcc under
> > Linux. 
>
>But your question has nothing to do with gcc or Linux, it is basic C
>programming.
>
> > In the program, I must use a pointer that point to
> > double pointers (int ***p) and I would be very
> > grateful if someone could tell me how to declare it
> > and reserve memory for it. 
>
>Please re-ask your question on a more appropriate list,
>or get a good C programming book.
>
>Sorry if this seems rude, but the purpose of this list
>is for communication between gcc developers and testers.
>If we allow it to turn into a list for helping beginning
>programmers, it is unfair to the folks who are working
>hard to make gcc a better compiler.


Christopher R. Jones, P.Eng.
14 Oneida Avenue
Toronto, Ontario M5J 2E3
Tel. 416 203-7465
Fax. 416 203-3044
Email cj@interlog.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]