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 of 32bit container

array of 32bit container

Scheduled Pinned Locked Moved C / C++ / MFC
c++comdockerdata-structurestutorial
10 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.
  • M Offline
    M Offline
    Member_14812342
    wrote on last edited by
    #1

    Good afternoon

    I am new in c++. I am trying to write a code that uses an array of 2 exponent 32, A small example is the code below.

    #include # include # include # include # include #include # include #include #include #include #include #define two_power(n) (1u << (n))
    using namespace std;

    typedef unsigned long word32;

    int main()
    {
    word32 delta, alfa;
    static word32 array[4294967295][4294967295] ={0};
    for (delta = 0; delta < 4294967296; delta++)
    {
    for (alfa = 0; alfa < 4294967296; alfa++)
    {
    array[delta][alfa] = alfa + delta;
    }
    }
    cout << array[4294967295][4294967295];
    return 0;
    }

    I there any method I can use to instead of using array because arrays have limitation in size. 2^32 = 4294967296. You can send me an email if you have an answer

    kdmuthavhine@gmail.com

    L J 2 Replies Last reply
    0
    • M Member_14812342

      Good afternoon

      I am new in c++. I am trying to write a code that uses an array of 2 exponent 32, A small example is the code below.

      #include # include # include # include # include #include # include #include #include #include #include #define two_power(n) (1u << (n))
      using namespace std;

      typedef unsigned long word32;

      int main()
      {
      word32 delta, alfa;
      static word32 array[4294967295][4294967295] ={0};
      for (delta = 0; delta < 4294967296; delta++)
      {
      for (alfa = 0; alfa < 4294967296; alfa++)
      {
      array[delta][alfa] = alfa + delta;
      }
      }
      cout << array[4294967295][4294967295];
      return 0;
      }

      I there any method I can use to instead of using array because arrays have limitation in size. 2^32 = 4294967296. You can send me an email if you have an answer

      kdmuthavhine@gmail.com

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      That is just crazy, you are trying to reserve 73,786,976,294,838,206,464 bytes in your program. And given that all your program does (or tries to do) is print the numbers from 1 to that value, it is rather a waste of time. You can use a single variable and write a loop that increments it from 1 to whatever final value you want, printing each value as it goes round the loop. You also do not need most of those #include statements; only include the ones you need.

      1 Reply Last reply
      0
      • M Member_14812342

        Good afternoon

        I am new in c++. I am trying to write a code that uses an array of 2 exponent 32, A small example is the code below.

        #include # include # include # include # include #include # include #include #include #include #include #define two_power(n) (1u << (n))
        using namespace std;

        typedef unsigned long word32;

        int main()
        {
        word32 delta, alfa;
        static word32 array[4294967295][4294967295] ={0};
        for (delta = 0; delta < 4294967296; delta++)
        {
        for (alfa = 0; alfa < 4294967296; alfa++)
        {
        array[delta][alfa] = alfa + delta;
        }
        }
        cout << array[4294967295][4294967295];
        return 0;
        }

        I there any method I can use to instead of using array because arrays have limitation in size. 2^32 = 4294967296. You can send me an email if you have an answer

        kdmuthavhine@gmail.com

        J Offline
        J Offline
        jeron1
        wrote on last edited by
        #3

        So you need 73.78 x 10^18 bytes? Wow! May I ask what you're using it for? Generally I'd use a vector instead of arrays and let the vector handle the memory allocations/deallocations, but I've never had to deal with numbers that large. I can't imagine your code being able to allocate that kind of space. The program you've posted is accessing an invalid array index, the largest index you can theoretically have is array[4294967294][4294967294], because there are 4294967295 entries in each dimension, entries 0-4294967294.

        "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

        Richard Andrew x64R M 2 Replies Last reply
        0
        • J jeron1

          So you need 73.78 x 10^18 bytes? Wow! May I ask what you're using it for? Generally I'd use a vector instead of arrays and let the vector handle the memory allocations/deallocations, but I've never had to deal with numbers that large. I can't imagine your code being able to allocate that kind of space. The program you've posted is accessing an invalid array index, the largest index you can theoretically have is array[4294967294][4294967294], because there are 4294967295 entries in each dimension, entries 0-4294967294.

          "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #4

          jeron1 wrote:

          because there are 4294967295 entries in each dimension

          Yes but he's writing his program in the fourth dimension!

          The difficult we do right away... ...the impossible takes slightly longer.

          J M 2 Replies Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            jeron1 wrote:

            because there are 4294967295 entries in each dimension

            Yes but he's writing his program in the fourth dimension!

            The difficult we do right away... ...the impossible takes slightly longer.

            J Offline
            J Offline
            jeron1
            wrote on last edited by
            #5

            Because in the fourth dimension no one can hear your allocation fail? :)

            "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

            M 1 Reply Last reply
            0
            • J jeron1

              Because in the fourth dimension no one can hear your allocation fail? :)

              "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

              M Offline
              M Offline
              Member_14812342
              wrote on last edited by
              #6

              What does my question has to deal with facebook and drinking behaviour?

              V 1 Reply Last reply
              0
              • Richard Andrew x64R Richard Andrew x64

                jeron1 wrote:

                because there are 4294967295 entries in each dimension

                Yes but he's writing his program in the fourth dimension!

                The difficult we do right away... ...the impossible takes slightly longer.

                M Offline
                M Offline
                Member_14812342
                wrote on last edited by
                #7

                So what is it that has to be done. I want to create Differential Distribution Table (DDT) of Blowfish algorithm. I have done for DES.

                1 Reply Last reply
                0
                • J jeron1

                  So you need 73.78 x 10^18 bytes? Wow! May I ask what you're using it for? Generally I'd use a vector instead of arrays and let the vector handle the memory allocations/deallocations, but I've never had to deal with numbers that large. I can't imagine your code being able to allocate that kind of space. The program you've posted is accessing an invalid array index, the largest index you can theoretically have is array[4294967294][4294967294], because there are 4294967295 entries in each dimension, entries 0-4294967294.

                  "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

                  M Offline
                  M Offline
                  Member_14812342
                  wrote on last edited by
                  #8

                  for Differential Distribution Table of Blowfish algorithm

                  L 1 Reply Last reply
                  0
                  • M Member_14812342

                    What does my question has to deal with facebook and drinking behaviour?

                    V Offline
                    V Offline
                    Victor Nijegorodov
                    wrote on last edited by
                    #9

                    Member 14812342 wrote:

                    What does my question has to deal with facebook and drinking behaviour?

                    Nothing. It was not an answer, just a signature! :laugh:

                    1 Reply Last reply
                    0
                    • M Member_14812342

                      for Differential Distribution Table of Blowfish algorithm

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      Well you cannot create it in memory like that. You need to rethink what you are trying to do and understand the hardware and software limitations of the system you are working on.

                      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