Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. C / C++ / MFC
  3. 2 dimensional dynamic arrays

2 dimensional dynamic arrays

Scheduled Pinned Locked Moved C / C++ / MFC
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex
    wrote on last edited by
    #1

    I am having problems building a 2 dimensional dynamic array. I built a one dimensional dynamic array, but I don't know were to start with a 2 dimensional. I cannot find any helpful documentation on it so far on it. Any comments?

    P 1 Reply Last reply
    0
    • A Alex

      I am having problems building a 2 dimensional dynamic array. I built a one dimensional dynamic array, but I don't know were to start with a 2 dimensional. I cannot find any helpful documentation on it so far on it. Any comments?

      P Offline
      P Offline
      Philip Nicoletti
      wrote on last edited by
      #2

      int nRows = 6; int nCols = 3; int ** cp; // Allocate rows cp = new int *[ nRows ]; // Now allocate using a loop for ( int index = 0; index < nRows; index++ ) { cp[index] = new int [ nCols ]; } cp[5][0] = 1; cp[5][1] = 2;

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups