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. stupid array initialization

stupid array initialization

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelptutorial
6 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.
  • H Offline
    H Offline
    happycpp
    wrote on last edited by
    #1

    hi everyone.. i'm having this stupid problem that i don't know how to solve: DWORD Size = GetFileSize(..); int Arr[Size]; the problem is that Arr doesn't accept Size to be the number of elements!!!

    B V H 3 Replies Last reply
    0
    • H happycpp

      hi everyone.. i'm having this stupid problem that i don't know how to solve: DWORD Size = GetFileSize(..); int Arr[Size]; the problem is that Arr doesn't accept Size to be the number of elements!!!

      B Offline
      B Offline
      brdavid
      wrote on last edited by
      #2

      I don't think arrays like to be dymically allocated. I think you have to give it a constant number. Try using CStringArray instead. Hope this helps.

      1 Reply Last reply
      0
      • H happycpp

        hi everyone.. i'm having this stupid problem that i don't know how to solve: DWORD Size = GetFileSize(..); int Arr[Size]; the problem is that Arr doesn't accept Size to be the number of elements!!!

        V Offline
        V Offline
        vcplusplus
        wrote on last edited by
        #3

        int *pArr = new int[Size];

        M K 2 Replies Last reply
        0
        • V vcplusplus

          int *pArr = new int[Size];

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          Actually you should use a BYTE array. Using an int array allocated 4 times the necessary space. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ----

          1 Reply Last reply
          0
          • H happycpp

            hi everyone.. i'm having this stupid problem that i don't know how to solve: DWORD Size = GetFileSize(..); int Arr[Size]; the problem is that Arr doesn't accept Size to be the number of elements!!!

            H Offline
            H Offline
            happycpp
            wrote on last edited by
            #5

            thanx very much..i used the allocating in the heap way since i'm not intending to use MFC (CMap)..

            1 Reply Last reply
            0
            • V vcplusplus

              int *pArr = new int[Size];

              K Offline
              K Offline
              Killer Coding Ninja Monkey
              wrote on last edited by
              #6

              Not sure in C++ (yet anyways) but in VB there is a keyword to resize the array and to save the info in the array. Killer coding ninja monkeys do exsist ! There is no spoon? How the frell do I eat my frosted mini-wheats

              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