Click here to Skip to main content
15,912,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ISAPI:what's different between <input type=submit value=submit> and <input type=image src=images/01.gif> to submit a Form? Pin
Junsong He21-Sep-01 0:22
Junsong He21-Sep-01 0:22 
Generalthe joys of windows nt security Pin
Nick Blumhardt20-Sep-01 16:22
Nick Blumhardt20-Sep-01 16:22 
Generalmemeory leakage (urjent) Pin
20-Sep-01 16:08
suss20-Sep-01 16:08 
GeneralRe: memeory leakage (urjent) Pin
Christian Graus20-Sep-01 16:17
protectorChristian Graus20-Sep-01 16:17 
GeneralRe: memeory leakage (urjent) Pin
Michael P Butler21-Sep-01 1:26
Michael P Butler21-Sep-01 1:26 
GeneralBMP Dialog box Pin
20-Sep-01 14:57
suss20-Sep-01 14:57 
GeneralDynamic allocation of multidimensional arrays Pin
Sprudling20-Sep-01 13:38
Sprudling20-Sep-01 13:38 
GeneralRe: Dynamic allocation of multidimensional arrays Pin
Sprudling20-Sep-01 14:53
Sprudling20-Sep-01 14:53 
This is the best I've managed to do so far...

#include "iostream.h"
 
int main(int argc, char* argv[])
{
   // Set the dimensions of the array
   int nA = 5;
   int nB = 4;
 
   // "Create" the 1. dimension of the array
   int** a = new int*[nA];
 
   // "Create" the 2. dimension of the array
   for (int i1 = 0; i1 < nA; i1++)
   {
      a[i1] = new int[nB];
   }
 
   // Initialize all the array elements
   for (i1 = 0; i1 < nA; i1++)
   {
      for (int i2 = 0; i2 < nB; i2++)
      {
         a[i1][i2] = (i1 * nB) + i2;
      }
   }
 
   // Print all the array elements to the screen
   for (i1 = 0; i1 < nA; i1++)
   {
      for (int i2 = 0; i2 < nB; i2++)
      {
         cout << "[" << i1 << "][" << i2 << "] : " << a[i1][i2] << endl;
      }
   }
 
   // Deallocate the array
   for (i1 = 0; i1 < nA; i1++)
   {
      delete[] a[i1];
   }
   delete[] a;
 
   return 0;
}

It seems to work ok, but there is alot of code just for creating an array, and I'll have to keep track of the size of the 1. dimension of the array, and that's not always simple.

Isn't there a better way? Confused | :confused:

Sprudling
GeneralRe: Dynamic allocation of multidimensional arrays Pin
Michael Dunn20-Sep-01 15:59
sitebuilderMichael Dunn20-Sep-01 15:59 
GeneralRe: Dynamic allocation of multidimensional arrays Pin
Nick Blumhardt20-Sep-01 16:07
Nick Blumhardt20-Sep-01 16:07 
GeneralRe: Dynamic allocation of multidimensional arrays Pin
Sprudling20-Sep-01 16:36
Sprudling20-Sep-01 16:36 
AnswerRe: Dynamic allocation of multidimensional arrays Pin
MehranNZ13-May-09 23:44
MehranNZ13-May-09 23:44 
GeneralTimeline Control Pin
JTAnderson20-Sep-01 12:40
JTAnderson20-Sep-01 12:40 
GeneralRe: Timeline Control Pin
Diarrhio21-Sep-01 0:49
Diarrhio21-Sep-01 0:49 
GeneralTerminating a Process Pin
20-Sep-01 11:43
suss20-Sep-01 11:43 
GeneralRe: Terminating a Process Pin
Ghazi H. Wadi20-Sep-01 12:55
Ghazi H. Wadi20-Sep-01 12:55 
GeneralRe: Terminating a Process Pin
20-Sep-01 12:58
suss20-Sep-01 12:58 
QuestionHow to enable sharing resources from an extension DLL? Pin
20-Sep-01 11:31
suss20-Sep-01 11:31 
AnswerRe: How to enable sharing resources from an extension DLL? Pin
Tomasz Sowinski20-Sep-01 11:46
Tomasz Sowinski20-Sep-01 11:46 
GeneralRe: How to enable sharing resources from an extension DLL? Pin
20-Sep-01 11:53
suss20-Sep-01 11:53 
Generalsubsplitter of splitter Pin
Peter Molnar20-Sep-01 10:11
Peter Molnar20-Sep-01 10:11 
GeneralRe: subsplitter of splitter Pin
Oscar Vazquez21-Sep-01 11:35
Oscar Vazquez21-Sep-01 11:35 
GeneralWindow paint problem when using CPropertySheet with CComboBox Pin
20-Sep-01 10:07
suss20-Sep-01 10:07 
GeneralStrange CTreeCtrl behavior Pin
Ken Goguen20-Sep-01 9:16
Ken Goguen20-Sep-01 9:16 
GeneralRe: Strange CTreeCtrl behavior Pin
Michael Dunn20-Sep-01 9:28
sitebuilderMichael Dunn20-Sep-01 9:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.