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. Help me plase :: Array of CString

Help me plase :: Array of CString

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelpquestion
3 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.
  • T Offline
    T Offline
    TooLeeDiN
    wrote on last edited by
    #1

    ... toMatrix(int row,int colum,CString matrix) { Cstring m[row][colum];//Why this line erroe????? return ...;// } I need return m to other function,plase tell the way. thank you.

    M K 2 Replies Last reply
    0
    • T TooLeeDiN

      ... toMatrix(int row,int colum,CString matrix) { Cstring m[row][colum];//Why this line erroe????? return ...;// } I need return m to other function,plase tell the way. thank you.

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #2

      you need to have a fixed size at compile time.


      Maximilien Lincourt Your Head A Splode - Strong Bad

      1 Reply Last reply
      0
      • T TooLeeDiN

        ... toMatrix(int row,int colum,CString matrix) { Cstring m[row][colum];//Why this line erroe????? return ...;// } I need return m to other function,plase tell the way. thank you.

        K Offline
        K Offline
        Kevin McFarlane
        wrote on last edited by
        #3

        Try something like this... // *************************************** // Example: Dynamic Multidimensional Array // *************************************** // We want both array dimensions to be allocated dynamically and // to be able to reference an element as x[i][j] // Here's how to do it... // *********** // MFC Version // *********** // Array of ints typedef CArray CIntArray; // Array of arrays of ints typedef CArray CMultiIntArray; void TraceDynamicArray(const unsigned int rows, const unsigned int columns) { CMultiIntArray aTest; // Allocate number of rows aTest.SetSize( rows ); // For each row for (int row = 0; row < aTest.GetSize(); row++) { // Allocate number of columns aTest[row].SetSize( columns ); // For each column for (int column = 0; column < aTest[row].GetSize(); column++) { // Assign a value aTest [row] [column] = 10 * row + column; // Trace it afxDump << aTest [row] [column] << "\t"; } afxDump << "\n"; } } In your case you need to have // Array of CString typedef CArray CStringArray; // Array of arrays of CString typedef CArray CMultiStringArray; Kevin

        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