Here I need to initialize an array all to zeros and to create an array of pointers and pass the array of pointers to the calculate function, however; I'm confused as how to do this, I've been looking online and it seems that I've created an array of pointers correctly but when i print it out to see what it looks like its all long weird numbers (i suspect addresses) and not 0s i had hoped for. Also how do i pass the array to the next function, i've read somewhere that I can't pass an array but i can pass an array of pointers, what is the syntax for that look like? Any help would be great!

void CMatrix::Init(int input)
{
     int row, col;

//     cout << "\n" << input;
     
     int **loc = 0;
     
     loc = new int*[input];
     
     for (row = 0; row < input; row++)
         loc[row] = new int[input];
     
     for (row = 0; row < input; row++)
     {
         for (col = 0; col < input; col++)
             cout << loc[row][col];
//             *(loc[row] + col) = col;  
             
         cout << "\n";
     }    
     
                                      
     row = 1;                              
     col = input/2 + 1;                    
     otherdiag = 0;
     
//     Calculate(input, &*loc);
     
     for (row = 0; row < input; row++)
         delete [] loc[row];
     
     delete [] loc;
}

Can you post a bit more code (the shortest compilable example)? Personally, I anytime I see **, I think there is a better way to go. Maybe you could use an std::vector<int*> or something like that?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.