473,804 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

huge numbers are not acceptable , why?

Hi there
In this code , I need a huge table , but for numbers more than 259025 it
crashes , why?
How to fix that problem?

void main(void)
{
int Sorted[1000000];
Sorted[1] = 1;
}

also i have a table like this :
myTable *table[1000000];
till here is ok , but :
table[i]=&anothertabl e;
again crashes for more than that number
please help me to fix these problems

Regards
ArShAm
Jul 19 '05 #1
6 1972
"ArShAm" <ar************ @hotmail.com> wrote in message
news:bo******** *****@ID-89294.news.uni-berlin.de...

Try this

int *Sorted = new int[1000000];

//do your stuff
delete [] Sorted;

Ali R.

Hi there
In this code , I need a huge table , but for numbers more than 259025 it
crashes , why?
How to fix that problem?

void main(void)
{
int Sorted[1000000];
Sorted[1] = 1;
}
also i have a table like this :
myTable *table[1000000];
till here is ok , but :
table[i]=&anothertabl e;
again crashes for more than that number
please help me to fix these problems

Regards
ArShAm

Jul 19 '05 #2

"Ali R." <no****@company .com> wrote in message news:Q2******** ***********@new ssvr11.news.pro digy.com...
"ArShAm" <ar************ @hotmail.com> wrote in message
news:bo******** *****@ID-89294.news.uni-berlin.de...

Try this

int *Sorted = new int[1000000];

or better
vector<int> Sorted(100000);
Jul 19 '05 #3
> In this code , I need a huge table , but for numbers more than 259025
it
crashes , why?
How to fix that problem?

void main(void)
{
int Sorted[1000000];
Sorted[1] = 1;
}
Most likely because you have run out of stack space. The Sorted array
stores its data on the stack, which is often a limited resource. Given
the number 259025 * sizeof(int), my guess is that the stack size on your
platform is 1 MByte. Also note that main() doesn't return void; main()
always returns int.

One way to get around the stack size limitation is to allocate the array
on the heap as Ali R. suggested. But an even better way to do it is to
use std::vector which also stores its data on the heap but doesn't
require explicit resource management:

#include <vector>

int main()
{
std::vector<int > Sorted(1000000) ;
Sorted[1] = 1;

// No need to delete anything!
return 0;
}
also i have a table like this :
myTable *table[1000000];
till here is ok , but :
table[i]=&anothertabl e;
again crashes for more than that number


The same problem. The reason that the line myTable *table[1000000]
doesn't crash immediately is that it doesn't generate executable code
with many compilers. However as soon as you start accessing elements it
will access memory that is beyond the stack, hence the crash. Again
using std::vector should fix this problem.

--
Peter van Merkerk
peter.van.merke rk(at)dse.nl


Jul 19 '05 #4
Thanks Ali jan
The problem is here : ==> Sorted[i]=i;
if you remove this section , program works ;

in my code , the main thing was this :
myClass* table[1000000];//to here , its ok
table[i]->datd=data;//here is problem , that program crashes
Thanks
ArShAm

"Ali R." <no****@company .com> wrote in message
news:Q2******** ***********@new ssvr11.news.pro digy.com...
"ArShAm" <ar************ @hotmail.com> wrote in message
news:bo******** *****@ID-89294.news.uni-berlin.de...

Try this

int *Sorted = new int[1000000];

//do your stuff
delete [] Sorted;

Ali R.

Hi there
In this code , I need a huge table , but for numbers more than 259025 it
crashes , why?
How to fix that problem?

void main(void)
{
int Sorted[1000000];
Sorted[1] = 1;
}


also i have a table like this :
myTable *table[1000000];
till here is ok , but :
table[i]=&anothertabl e;
again crashes for more than that number
please help me to fix these problems

Regards
ArShAm


Jul 19 '05 #5
ArShAm wrote:
Thanks Ali jan
The problem is here : ==> Sorted[i]=i;
if you remove this section , program works ;

in my code , the main thing was this :
myClass* table[1000000];//to here , its ok
table[i]->datd=data;//here is problem , that program crashes
Thanks
ArShAm


1. Don't top-post. Replies are interwoven or appended to the
bottom of a reply, like this one.
2. We need to see your class declaration and the smallest amount
of "compilable " code which demonstrates the issue.
3. Tell us what the expected behavior is and the actual behavior.
4. The possibilities:
4.1. Operator -> is overloaded incorrectly.
4.2. Operator = is overloaded incorrectly.
4.3. The index variable, i, is out of range.
4.4. The index variable, i, is a floating point value.
4.5. The compiler could not find a conversion function for
converting "data" to "datd" (if necessary).
As you can see, there are many possibilities, but we can't
narrow them down until you show some code (see #2 above).

Please read the Welcome.Txt and C++ FAQs below. They will
provide information on how to post as well as other excellent
information.

--
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.l earn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 19 '05 #6
"ArShAm" <ar************ @hotmail.com> wrote in message
news:bo******** *****@ID-89294.news.uni-berlin.de...
Thanks Ali jan
The problem is here : ==> Sorted[i]=i;
if you remove this section , program works ;

in my code , the main thing was this :
myClass* table[1000000];//to here , its ok
table[i]->datd=data;//here is problem , that program crashes

Well, now you are posting different problem. You are declaring an array of
pointers to your class but you aren't initializing the array with anything.

In this case you would use the vector class

vector<myClass> Table(1000000);

or if you are getting the pointers to the objects from someplace else

vector<myClass *> Table(1000000);

Thanks
ArShAm

"Ali R." <no****@company .com> wrote in message
news:Q2******** ***********@new ssvr11.news.pro digy.com...
"ArShAm" <ar************ @hotmail.com> wrote in message
news:bo******** *****@ID-89294.news.uni-berlin.de...

Try this

int *Sorted = new int[1000000];

//do your stuff
delete [] Sorted;

Ali R.

Hi there
In this code , I need a huge table , but for numbers more than 259025 it crashes , why?
How to fix that problem?

void main(void)
{
int Sorted[1000000];
Sorted[1] = 1;
}


also i have a table like this :
myTable *table[1000000];
till here is ok , but :
table[i]=&anothertabl e;
again crashes for more than that number
please help me to fix these problems

Regards
ArShAm



Jul 19 '05 #7

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

Similar topics

4
2368
by: t | last post by:
Hello, I am going to write a program to search for prime numbers. There will be a lot of clients participating in this searching so I have to operate on very huge numbers, bigger than can be stored in double... I wonder how can I deal with this numbers? Do I have to create an array of doubles or ints? How could I make calculations on numbers stored in such an array? Could you give me some ideas? Or maybe you could send me source of any
5
4165
by: mas | last post by:
I have a Stored Procedure (SP) that creates the data required for a report that I show on a web page. The SP does all the work and just returns back a results set that I dump in an ASP.NET DataGrid. The SP takes a product area and a start and end date as parameters. Here are the basics of the SP. 1. Create temp table to store report results, all columns are created that will be needed at this point. 2. Select products and general...
96
6352
by: Gustav Hllberg | last post by:
I tried finding a discussion around adding the possibility to have optional underscores inside numbers in Python. This is a popular option available in several "competing" scripting langauges, that I would love to see in Python. Examples: 1_234_567 0xdead_beef 3.141_592
5
1729
by: John | last post by:
Hi, I've always had the opinion that you don't store credit card numbers on a hosted website database. But it has occurred to me, that perhaps I am over reacting, and encrypted CC info may be ok. Now I know basic encryption, but am not confident that I know what I don't know .. you know. Basically, am I over reacting? Is the risk level acceptable if you store encrypted CC numbers or not?
6
3812
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for one day): \\FFDS24\ASP.NET Applications(_LM_W3SVC_1_Root_ATV2004)\Errors During Execution: 7 \\FFDS24\ASP.NET Apps v1.1.4322(_LM_W3SVC_1_Root_ATV2004)\Compilations
7
1603
by: Peter Hansen | last post by:
Is in any way possible to define a variable as a integer-value which contain about 300 numbers in a row? I have thought about an Override-function for Data-types but I dunno how - but if it is possible that a Data-type which can hold an unlimited numbers of numbers :D exists I would be happy or if it is possible to Override the Dim-function... Hilsen fra Peter
9
1760
by: Vjay77 | last post by:
I am working on the program where is necessary to calculate huge amount of numbers in always the same sequence. In other words, these number have to be calculated and saved into memory before the program starts. I was trying to use number pi, but to calculate 100 million decimal places of number pi would take forever and no one would want to wait that long. On the other hand I can't afford to include the whole 100 million dec. places...
8
4281
by: blaine | last post by:
Hey guys, For my Network Security class we are designing a project that will, among other things, implement a Diffie Hellman secret key exchange. The rest of the class is doing Java, while myself and a classmate are using Python (as proof of concept). I am having problems though with crunching huge numbers required for calculations. As an alternative I can use Java - but I'd rather have a pure python implementation. The problem is that...
9
13240
by: NvrBst | last post by:
Whats the best way to count the lines? I'm using the following code at the moment: public long GetNumberOfLines(string fileName) { int buffSize = 65536; int streamSize = 65536; long numOfLines = 0; byte bArr = new byte;
0
9710
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10593
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9163
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.