Multi Dimensional Arrays

Hi all,

I need to create double arrays in 3 dimensions. The 3 dimensions are height and width of an image, with the 3rd containing rgb data for each pixel. Unfortunately, it seems that there is a limit on the size the array can be, and trying to instantiate a double array like so:

double fRe[IMGX][IMGY][3];

causes the program to crash out for any values of sizeof(double) * IMGX * IMGY * 3 above ~1,900,000. Can anyone suggest a decent solution for this problem? Creating the array on the heap seems like a lot of work for something so trivial. Plus I'm something of a C++ newbie :S
see this, a double pointer implementation using malloc:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//allocating memory to char ** and using
int main()
{
	char **ptr,*temp;
	int i;

	ptr = (char **)malloc(2 * sizeof(char *));
	temp = (char *)malloc(20 * sizeof(char *));

	for(i=0;i<2;i++)
	{
		*(ptr + i) = (char *)malloc(10 * sizeof(char *));
	}

	i=0;
	while(i<2)
	{
		printf("Enter %d: ",i+1);
		gets(temp);
		strcpy(*(ptr + i),temp);
		printf("\n");
		i++;
	}

	i=0;
	while(i<2)
	{
		printf("%s\n",*(ptr + i));
		i++;
	}

	free(*(ptr+0));
	free(*(ptr+1));
	free(ptr);
	free(temp);

	return 0;
}


a triple pointer can be implemented similarly..
Topic archived. No new replies allowed.