Size of Arrays

Joined
Jan 28, 2012
Messages
24
Reaction score
0
Points
1
I have 4 gigabits of memory but in Xcode the largest array I have been able to assign is [25000][81]. I am working with Sudoku puzzles. That does not fill my memory how do I set larger arrays? Help please.
Warren Trammell
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Moved thread to more appropriate forum.

I'm not a professional programmer (nor do I even like ObjC) but what kind of array are you trying to create? Some sample code would also help.
 
OP
W
Joined
Jan 28, 2012
Messages
24
Reaction score
0
Points
1
Allowable array size

I am trying to read into memory a large group of Sudoku puzzles by declaring an int array[x][81] where x is 49151 but the largest Xcode will allow is something under 25000.
Warren
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Have you tried using NSArray instead?
 
OP
W
Joined
Jan 28, 2012
Messages
24
Reaction score
0
Points
1
#include <iostream>

FILE *reed;

int main(int argc, const char * argv[])
{
int a, b, array[25879][81];

if((reed = fopen("//Users//warren//documents//misc//sudoku17","r")) == NULL)
{
printf("\n Can't open input file for reading:");
exit(1);
} // insert code here...
for(a = 0; a < 25000; a++)
{
for(b = 0; b < 81; b++)
{
fscanf(reed,"%i",&array[a]);
}
}
return 0;
}
That is the largest array Xcode will accept.It balks at 25880.
Changing the name of the variable probably will not help.
Warren
 
Joined
Dec 8, 2009
Messages
453
Reaction score
10
Points
18
Location
The same as Sheldon Cooper - East Texas
Your Mac's Specs
iMac 2014 i5 5k 32gb 1tb fusion, second TB display, 2014 MBA
IMO you are taking the long way around. Instead of trying to use an array with humongous indexes, why not just use a lightweight database like SQLITE and dump your puzzles into that? It looks like you are trying to do exactly one of the things that a DB is good for. For one thing, you wouldn't have to load that huge array every time you ran the program - it would just be setting there on disk waiting to be used.

If you've mastered Xcode, sqlite3 would be nothing to learn. Or even the open source version of MySql.

Just an idea.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top