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. Array/List?

Array/List?

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structures
7 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.
  • D Offline
    D Offline
    DaFrawg
    wrote on last edited by
    #1
    1. I'm sorry, but I know this is a real newbie-question: how do I make an array for for instance UINT's or doubles, or CButtons? 2) Is there a possibility to determine (fast!) what the highest or lowest value in an UINT- or doubles-array or list is? I need this, because I've planned to make 1) my very own CHistogramCtrl 2) a (useless) dialog, containing one button, that devides itself into 4 new ones after clicking on it (and so on: click on one of the new buttons and it will start over again).
    D K 2 Replies Last reply
    0
    • D DaFrawg
      1. I'm sorry, but I know this is a real newbie-question: how do I make an array for for instance UINT's or doubles, or CButtons? 2) Is there a possibility to determine (fast!) what the highest or lowest value in an UINT- or doubles-array or list is? I need this, because I've planned to make 1) my very own CHistogramCtrl 2) a (useless) dialog, containing one button, that devides itself into 4 new ones after clicking on it (and so on: click on one of the new buttons and it will start over again).
      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      DaFrawg wrote: how do I make an array for for instance UINT's or doubles, or CButtons? UINT uArray[5]; double dArray[10]; CButton btnArray[3]; DaFrawg wrote: 2) Is there a possibility to determine (fast!) what the highest or lowest value in an UINT- or doubles-array or list is? The lowest value is always going to be zero. The highest value is always going to be the number of elements minus 1; int nCount = (sizeof(uArray) / sizeof(UINT)) - 1; Since you are using MFC, you might want to look at the CArray-related classes.

      K 1 Reply Last reply
      0
      • D David Crow

        DaFrawg wrote: how do I make an array for for instance UINT's or doubles, or CButtons? UINT uArray[5]; double dArray[10]; CButton btnArray[3]; DaFrawg wrote: 2) Is there a possibility to determine (fast!) what the highest or lowest value in an UINT- or doubles-array or list is? The lowest value is always going to be zero. The highest value is always going to be the number of elements minus 1; int nCount = (sizeof(uArray) / sizeof(UINT)) - 1; Since you are using MFC, you might want to look at the CArray-related classes.

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

        DavidCrow wrote: The lowest value is always going to be zero. The highest value is always going to be the number of elements minus 1 Doesn't he mean the element with the largest value? Kevin

        D 1 Reply Last reply
        0
        • K Kevin McFarlane

          DavidCrow wrote: The lowest value is always going to be zero. The highest value is always going to be the number of elements minus 1 Doesn't he mean the element with the largest value? Kevin

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          I'm not real sure. Even though the word 'value' was used, I took it with a grain of salt. Folks' use of words in these forums vary so much, it's hard to assume anything.


          Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

          1 Reply Last reply
          0
          • D DaFrawg
            1. I'm sorry, but I know this is a real newbie-question: how do I make an array for for instance UINT's or doubles, or CButtons? 2) Is there a possibility to determine (fast!) what the highest or lowest value in an UINT- or doubles-array or list is? I need this, because I've planned to make 1) my very own CHistogramCtrl 2) a (useless) dialog, containing one button, that devides itself into 4 new ones after clicking on it (and so on: click on one of the new buttons and it will start over again).
            K Offline
            K Offline
            Kevin McFarlane
            wrote on last edited by
            #5

            How much of a beginner are you? Are you a beginner of VC++/MFC only or are you also fairly new to C++? Apart from David's answer below you could also try using the vector class with the max_element algorithm. If you type "max_element" in the Help index and click on the Sample program link there is an example showing how to use it. It is also possible to use max_element on a raw array, if you find that easier to get your head round. double histogram[] = { 1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4 }; int count = sizeof(histogram) / sizeof(histogram[0]); double* begin = histogram; double* end = histogram + count; double* maximum = max_element(begin, end); afxDump << "Maximum = " << *maximum << "\n"; // or use TRACE You should also "include " Kevin

            K D 2 Replies Last reply
            0
            • K Kevin McFarlane

              How much of a beginner are you? Are you a beginner of VC++/MFC only or are you also fairly new to C++? Apart from David's answer below you could also try using the vector class with the max_element algorithm. If you type "max_element" in the Help index and click on the Sample program link there is an example showing how to use it. It is also possible to use max_element on a raw array, if you find that easier to get your head round. double histogram[] = { 1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4 }; int count = sizeof(histogram) / sizeof(histogram[0]); double* begin = histogram; double* end = histogram + count; double* maximum = max_element(begin, end); afxDump << "Maximum = " << *maximum << "\n"; // or use TRACE You should also "include " Kevin

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

              #include Kevin

              1 Reply Last reply
              0
              • K Kevin McFarlane

                How much of a beginner are you? Are you a beginner of VC++/MFC only or are you also fairly new to C++? Apart from David's answer below you could also try using the vector class with the max_element algorithm. If you type "max_element" in the Help index and click on the Sample program link there is an example showing how to use it. It is also possible to use max_element on a raw array, if you find that easier to get your head round. double histogram[] = { 1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4 }; int count = sizeof(histogram) / sizeof(histogram[0]); double* begin = histogram; double* end = histogram + count; double* maximum = max_element(begin, end); afxDump << "Maximum = " << *maximum << "\n"; // or use TRACE You should also "include " Kevin

                D Offline
                D Offline
                DaFrawg
                wrote on last edited by
                #7

                I'm a beginner of VC++/MFC, but I still don't get some C++ basics, like working with 'friend' and 'operator' and arrays, especially when they're declared to be a class member (this isn't good English, is it?). But if I understand it well, max_element is a macro (or function, whatever) in <algorithm.h>. Is that correct? If it is, it'd really help me.

                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