Double array

Good afternoon

I am new in c++. I am trying to write a code that uses an array of 2 exponent 32, A small example is the code below.


#include <iostream>
# include <stdio.h>
# include <fstream>
# include <string.h>
# include <iostream>
#include <math.h>
# include <stdlib.h>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <limits>
#define two_power(n) (1u << (n))
using namespace std;


typedef unsigned long word32;

int main()
{
word32 delta, alfa;
static word32 array[4294967295][4294967295] ={0};
for (delta = 0; delta < 4294967296; delta++)
{
for (alfa = 0; alfa < 4294967296; alfa++)
{
array[delta][alfa] = alfa + delta;
}
}
cout << array[4294967295][4294967295];
return 0;
}



I there any method I can use to instead of using array because arrays have limitation in size. 2^32 = 4294967296. You can send me an email if you have an answer

kdmuthavhine@gmail.com

To store a square matrix of 32-bit integers of side 2^32-1 you would need roughly 67 million terabytes. If you buy a datacenter or ten you might be able to store that much information.

What are you trying to do? Matrix multiplication or something?
cmath is c++ for math.h which is C. including both is of no use and can actually cause problems.

cstring is string.h, as above. neither should be used if you can use c++ <string> instead; only special cases / rare things should use C strings.

macros are not recommended if they can be avoided.

there are already over 100 names for integers, did you really need to typedef a new one?

using namespace std is bad practice, see many articles here or on web about why.

I am not picking on you, but you said you were new and these things are a mix of bad practices that will bite you when your programs get larger or if you get into a large project or try to code professionally.

Arrays defined this way need to be one solid block of memory, and as already said the size requested is insurmountable on any normal machine. If you can explain why you need this much space, and what you are doing, we can help you find a better way.
You can send me an email if you have an answer

I'll give you an answer here in the open forum where you practically demanded our assistance for free.

Not gonna happen.

If we do decide to help you it will be here, where others can benefit from what transpires.

Posting an email address in a public forum is one HUGE invite to get spammed and spammed hard.
Topic archived. No new replies allowed.