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

T

Thomas Matthews

Andi said:
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
 
W

William Payne

Andi Tse said:
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
 
P

PKH

Andi Tse said:
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
 
V

Vaclav Haisman

....or maybe you are using Borland C++ 3.1? If so you should really switch to
something better.

VH
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top