How to make a C++ array which have size bigger than 32767

Discussion in 'C++' started by Andi Tse, Sep 23, 2004.

  1. Andi Tse

    Andi Tse Guest

    I found it is not work when I access myarray[32768]. Thx.
     
    Andi Tse, Sep 23, 2004
    #1
    1. Advertising

  2. Andi Tse wrote:
    > I found it is not work when I access myarray[32768]. Thx.

    Show your code.

    What is the array type?

    There is a big difference in size of an array between
    an array of char and an array of float or a large class.

    Have you tried allocating using operator new?

    Have you checked your compiler documents to see if there
    is a limit to the quantity of elements in an array?

    Have you checked your compiler documentation to see if
    there is a size restriction for an array declared as
    auto?


    --
    Thomas Matthews

    C++ newsgroup welcome message:
    http://www.slack.net/~shiva/welcome.txt
    C++ Faq: http://www.parashift.com/c -faq-lite
    C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    alt.comp.lang.learn.c-c++ faq:
    http://www.comeaucomputing.com/learn/faq/
    Other sites:
    http://www.josuttis.com -- C++ STL Library book
     
    Thomas Matthews, Sep 23, 2004
    #2
    1. Advertising

  3. "Andi Tse" wrote:
    >I found it is not work when I access myarray[32768]. Thx.


    Hi Andi, not a very informative post. Sounds to me like you're trying to
    create a very large array on the stack, and that won't work because the
    stack relatively very small.
    Try dynamic allocation, i.e., using new. For example:
    char* foo = new char[some_big_integer_constant];
    Don't forget to deallocate with a corresponding call to delete [].
    Or you could use one of the many containers provided by the STL.

    / WP
     
    William Payne, Sep 23, 2004
    #3
  4. Andi Tse

    PKH Guest

    "Andi Tse" <> wrote in message
    news:...
    >I found it is not work when I access myarray[32768]. Thx.


    Maybe you are using 16 bits int's to access it ? If you switch to unsigned
    int's you can access up to 65535, or switch to 32-bits unsigned integers
    (dword) where the limit is 2^32 - 1 which is > 4.2 billion.
    Just guessing .

    PKH
     
    PKH, Sep 23, 2004
    #4
  5. ....or maybe you are using Borland C++ 3.1? If so you should really switch to
    something better.

    VH

    "Andi Tse" <> wrote in message
    news:...
    >I found it is not work when I access myarray[32768]. Thx.
     
    Vaclav Haisman, Sep 24, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rahmi Acar
    Replies:
    0
    Views:
    349
    Rahmi Acar
    Apr 20, 2004
  2. TG
    Replies:
    3
    Views:
    504
    Robert Kern
    Jul 26, 2006
  3. Replies:
    2
    Views:
    794
    Filip Larsen
    Apr 10, 2007
  4. Yannick Turgeon

    App getting bigger and bigger

    Yannick Turgeon, Oct 13, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    149
    Yannick Turgeon
    Oct 14, 2003
  5. Peng Yue
    Replies:
    7
    Views:
    206
    Peng Yue
    Sep 10, 2004
Loading...

Share This Page