creating a huge int massive

Hallo all! I'm new there and to C++.

I need to create a massive that can store 1000000 int type numbers. But whenever I try to compile my program it just.. well, stops working/crashes.

So how do I do that?
That will require 1.000.000 * sizeof (int) memory, assuming sizeof(int) == 4, you'll need ~ 4 Gb of working memory only for that. Don't you think it's too much?
What do you need that for?
Oh my... (o.0);

Well, its for school. I'm supposed to compare 2 sorting algorithms to figure out which one is faster. Bubblesort and quickstort.

We are supposed to compare their speed when we have a massive of the size of 10, 1000 and 1000000.

Well, I goes that I won't be doing the 1m than. I will probably just use a smaller one instead.. :/

Thank you! :)
Last edited on
Not 4 Gb, but only 4 Mb. This is quite possible. Most probably, the problem is that you try to allocate the memory in program stack.
Shadox, make the array global, allocate the memory dynamically or increase the stack size with the help of compiler options.
Not 4 Gb, but only 4 Mb.

You're right, sorry.
Topic archived. No new replies allowed.