473,394 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Array

I need to have two arrays with 480,000 elements each. When I try to
execute the program that contains this command I receive an error
window (in Windows) ( "error using miprogram_in_c.exe" ). What is the
array element size limit for c++? What can I do in order to have a two
480K array elements?
Jul 22 '05 #1
7 2828

"mabauti" <ma*****@yahoo.com> wrote in message
news:1f*************************@posting.google.co m...
I need to have two arrays with 480,000 elements each. When I try to
execute the program that contains this command I receive an error
window (in Windows) ( "error using miprogram_in_c.exe" ). What is the
array element size limit for c++? What can I do in order to have a two
480K array elements?


Use a vector instead of an array. You don't say what type your array is,
I'll assume it is an int array.

#include <vector>

std::vector<int> one_big_vector(480000);
std::vector<int> another_big_vector(480000);

int main()
{
// do whatever with the vectors
}

You can use vectors pretty much like arrays (and a whole lot more).

But you are dealing with very large amounts of memory still, so I can't
guarantee that this will work or that it is a sensible thing to do. The
other option is to redesign your program so that it doesn't need so much
memory or so that it doesn't need so much memory in a contiguous block. If
you explain why you need so much memory then maybe I will be able to suggest
some improvements.

john
Jul 22 '05 #2

"mabauti" <ma*****@yahoo.com> wrote in message
news:1f*************************@posting.google.co m...
I need to have two arrays with 480,000 elements each. When I try to
execute the program that contains this command I receive an error
window (in Windows) ( "error using miprogram_in_c.exe" ). What is the
array element size limit for c++? What can I do in order to have a two
480K array elements?


Did you declare the arrays statically? You should consider using dynamic
memory allocation or use one of the standard library´s containers. However,
what exactly do you need such big arrays for? Are you sure that this problem
can´t be optimized so that you´ll get along with a lower number of elements?

Cheers
Chris
Jul 22 '05 #3
mabauti posted:
I need to have two arrays with 480,000 elements each. When I try to
execute the program that contains this command I receive an error
window (in Windows) ( "error using miprogram_in_c.exe" ). What is the
array element size limit for c++? What can I do in order to have a two
480K array elements?

int array1[480000];
int array2[480000];

or:

int* p_array1 = new int[480000];
int* p_array2 = new int[480000];
-JKop
Jul 22 '05 #4
mabauti wrote:
I need to have two arrays with 480,000 elements each. When I try to
execute the program that contains this command I receive an error
window (in Windows) ( "error using miprogram_in_c.exe" ). What is the
array element size limit for c++? What can I do in order to have a two
480K array elements?


The C++ language specifies a minimum capacity for arrays in order
for compliance. Each implementation may exceed that minimum.
For example, if the C++ language said that a platform must support
100 integer elements, a platform is allowed to support 1024
integer elements. A non-conforming platform can support less
than the minimum. In either case, the compiler manufacturer
must state what the maximum capacity is for an array. These
values must be stated for automatic, local and dynamically
allocated arrays.

So, check your compiler documentation to see what the limits
are. You could experiment too. Generally, compilers have
smaller limits on automatic and locally declared arrays than
dynamically allocated arrays.
--
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

Jul 22 '05 #5
Thomas Matthews wrote:
The C++ language specifies a minimum capacity for arrays in order
for compliance.


It does not. Both the C and C++ recommendations for implementation
limits are "informative" and have no bearing on compliance.
Jul 22 '05 #6
Ron Natalie <ro*@sensor.com> wrote in message news:<41***********************@news.newshosting.c om>...
Thomas Matthews wrote:
The C++ language specifies a minimum capacity for arrays in order
for compliance.


It does not. Both the C and C++ recommendations for implementation
limits are "informative" and have no bearing on compliance.


Thank you.
I solved my problem by using dynamic memory allocation
Jul 22 '05 #7
Ron Natalie <ro*@sensor.com> wrote in message news:<41***********************@news.newshosting.c om>...
Thomas Matthews wrote:
The C++ language specifies a minimum capacity for arrays in order
for compliance.


It does not. Both the C and C++ recommendations for implementation
limits are "informative" and have no bearing on compliance.


In the case of C++, I believe that's correct. C, however, does have
_some_ normative lower limits, including the fact that:

The implementation shall be able to translate and execute at
least one instance of every one of the following limits:
....
65535 bytes in an object (in a hosted environment only).

OTOH, meeting the requirement only requires being able to execute one
specific program with a 64K object, not all possible programs that
contain it -- and I don't even see a requirement for documentation of
this particular program either. As such, the requirement is weak
nearly to the point of unenforceable, but normative nonetheless.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brian | last post by:
I'm diddlying with a script, and found some behavior I don't understand. Take this snippet: for ($i = 0; $i <= count($m); $i++) { array_shift($m); reset($m); }
2
by: Stormkid | last post by:
Hi Group I'm trying to figure out a way that I can take two (two dimensional) arrays and avShed and shed, and subtract the matching elements in shed from avShed I've pasted the arrays blow from a...
15
by: lawrence | last post by:
I wanted to test xml_parse_into_struct() so I took the example off of www.php.net and put this code up on a site: <?php $simple = <<<END <item>
8
by: vcardillo | last post by:
Hello all, Okay, I am having some troubles. What I am doing here is dealing with an employee hierarchy that is stored in an array. It looks like this: $employees = array( "user_id" => array(...
12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
8
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
7
by: Jim Carlock | last post by:
Looking for suggestions on how to handle bad words that might get passed in through $_GET variables. My first thoughts included using str_replace() to strip out such content, but then one ends...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.