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. General Programming
  3. C / C++ / MFC
  4. pointers and array[][][]

pointers and array[][][]

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structureshelptutoriallearning
4 Posts 3 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.
  • C Offline
    C Offline
    chapin
    wrote on last edited by
    #1

    Hi Im a c++ beginner, I was wondering if someone could help me with using pointers and triangular arrays. I would like to know how to define them correctly, accesing them and finally printing them with a for cycle.:doh:thanks! links to faqs and tutorials are also greatly appreciated;)

    V 1 Reply Last reply
    0
    • C chapin

      Hi Im a c++ beginner, I was wondering if someone could help me with using pointers and triangular arrays. I would like to know how to define them correctly, accesing them and finally printing them with a for cycle.:doh:thanks! links to faqs and tutorials are also greatly appreciated;)

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      Here is one solution. char ***pArray = new char **[1]; pArray[0] = new char *[1]; pArray[0][0] = new char[32]; ... delete [] pArray[0][0]; delete pArray[0]; delete pArray; Kuphryn

      C 1 Reply Last reply
      0
      • V valikac

        Here is one solution. char ***pArray = new char **[1]; pArray[0] = new char *[1]; pArray[0][0] = new char[32]; ... delete [] pArray[0][0]; delete pArray[0]; delete pArray; Kuphryn

        C Offline
        C Offline
        chapin
        wrote on last edited by
        #3

        ok, now how would i point to a specific direction and print that? lets say^i have a an array[7][20][50]; and i would like to print it by pointers, how would i do that? or if i would like to print all rows position five etc... thanks for your time:laugh:

        S 1 Reply Last reply
        0
        • C chapin

          ok, now how would i point to a specific direction and print that? lets say^i have a an array[7][20][50]; and i would like to print it by pointers, how would i do that? or if i would like to print all rows position five etc... thanks for your time:laugh:

          S Offline
          S Offline
          Selevercin
          wrote on last edited by
          #4

          int *iArray; iArray = new int [7][20][50]; // set values here for (int x = 0; x < 20; x++) { for (int y = 0; y < 50; y++) { // however you want to print... // i.e. cout << iArray[5][x][y] << endl; } }
          Hope that's helpful. If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.

          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