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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Array traversal

Array traversal

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelptutorialquestion
5 Posts 5 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
    T RATHA KRISHNAN
    wrote on last edited by
    #1

    Hi! I've two arrays. One array of strings. Another one of StaticText boxes. I've to read the array from the end and set each string to the StaticText element starting from the beginning(i.e I've to set the last text to the first static text element). Can anyone help me how to traverse these two arrays?

    _ K 2 Replies Last reply
    0
    • T T RATHA KRISHNAN

      Hi! I've two arrays. One array of strings. Another one of StaticText boxes. I've to read the array from the end and set each string to the StaticText element starting from the beginning(i.e I've to set the last text to the first static text element). Can anyone help me how to traverse these two arrays?

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      Traverse array with static boxes from top to bottom and use another variable to get the values from the second array. Ex: NO_OF_ELEMENTS is the number of elements you have in the arrays and number should be the same for both the arrays for (i=0;i < NO_OF_ELEMENTS;i++) { // And do something like //m_stArray[NO_OF_ELEMENTS-i].SetWindowText (m_strArray[i]); }

      I am a HUMAN. I have that keyword (??? too much) in my name........ ;-)_AnsHUMAN_b>

      E N 2 Replies Last reply
      0
      • T T RATHA KRISHNAN

        Hi! I've two arrays. One array of strings. Another one of StaticText boxes. I've to read the array from the end and set each string to the StaticText element starting from the beginning(i.e I've to set the last text to the first static text element). Can anyone help me how to traverse these two arrays?

        K Offline
        K Offline
        KarstenK
        wrote on last edited by
        #3

        make the IDs of the boxes in order or fetch their handles in an array... it works fine

        Press F1 for help or google it. Greetings from Germany

        1 Reply Last reply
        0
        • _ _AnsHUMAN_

          Traverse array with static boxes from top to bottom and use another variable to get the values from the second array. Ex: NO_OF_ELEMENTS is the number of elements you have in the arrays and number should be the same for both the arrays for (i=0;i < NO_OF_ELEMENTS;i++) { // And do something like //m_stArray[NO_OF_ELEMENTS-i].SetWindowText (m_strArray[i]); }

          I am a HUMAN. I have that keyword (??? too much) in my name........ ;-)_AnsHUMAN_b>

          E Offline
          E Offline
          Emilio Garavaglia
          wrote on last edited by
          #4

          In different format, but sometimes preferable (although it is a matter of taste)

          for(int i=0, j=N-1; i<N; ++i,--j)
          a[i].operation_on(b[j]);

          use two indexes, but does not recalculate the offsets.

          2 bugs found. > recompile ... 65534 bugs found. :doh:

          1 Reply Last reply
          0
          • _ _AnsHUMAN_

            Traverse array with static boxes from top to bottom and use another variable to get the values from the second array. Ex: NO_OF_ELEMENTS is the number of elements you have in the arrays and number should be the same for both the arrays for (i=0;i < NO_OF_ELEMENTS;i++) { // And do something like //m_stArray[NO_OF_ELEMENTS-i].SetWindowText (m_strArray[i]); }

            I am a HUMAN. I have that keyword (??? too much) in my name........ ;-)_AnsHUMAN_b>

            N Offline
            N Offline
            Niklas L
            wrote on last edited by
            #5

            for (i=0;i < NO_OF_ELEMENTS;i++)
            {
            // And do something like
            m_stArray[NO_OF_ELEMENTS-i -1 ].SetWindowText (m_strArray[i]);
            }

            :)

            home

            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