pointer to pointer errors

I am writing a piece of code which stores a large number of unsigned integers (about 250 Million of them), so I used something like:

1
2
3
unsigned int *locations[250];
for (int a=0; a<250; a++)
 locations[a]=new unsigned int[1000000];


and filled it with my numbers. What I want to do is be able to have pointers to specific integers that meet some condition, and I will need slightly under 70 million of them. I used:

1
2
3
unsigned int **special[70];
for (int b=0; b<70; b++)
  speicial[b]=new unsigned int *[1000000];


My problem is setting the special locations. I tried using:

 
(*speicial[i]+j)=(location[x]+y);


to get a location into speicial, but I get a non-lvalue in assignment error message. I also tried
 
*(special[i]+j)=(location[x]+y);

which produces seg faults. I assume this is because it goes to the ith+jth position in speicial and I quickly get out of bounds. What do I need to be doing to get this to work?
The first is like writing int x; x+2 = 7;. Thus the error.
The second should work. There must be bounds problems. Though it would be better to write it as
special[i][j] = &location[x][y]; to make it readable.

Post some more code if you need help with fixing the bounds problem.
Last edited on
You are correct. It was a bounds error. Both the second way and the way you suggested seem to be working. Thanks :)
Topic archived. No new replies allowed.