How can I store a large number of elements in an array?

  • 0
    Tell me how to store data, the amount of which exceeds the maximum value of the int type? You can't use the index ...
    C++ Isaiah Hall, Jul 14, 2020

  • 6 Answers
  • 0
    If I'm not mistaken, size_t is used as the array index, which corresponds to the maximum memory size for a processor with a given bit rate. That is, the situation you described cannot happen in principle.


    en.cppreference.com/w/cpp/types/size_t
    Aria Ray

  • 0

  • 0
    Use long type for index.


    and for storage, use several arrays of the maximum size and, depending on the index value, calculate the real index of the desired array
    Eli Noble

  • 0
    relative to any language, you can build a structure in which there will be an array of references to other arrays and the GetValue function with any type as a parameter, then determine in which array this element lies, for example, as a result of dividing the parameter by the maximum number of elements in the array, the remainder of this division will be the number of the element in the array. But in fact, the presence of a need for such a large array indicates the incorrectness of the application architecture, the task itself needs to be revised.
    Anonymous

  • 0
    Thanks for answers!
    Anonymous

  • 0
    How are you going to work with such data sizes at all? Here it is already necessary to dig in the direction of displaying files in memory.
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!